Browse Source

Exporters: Remove Geometry support.

Mugen87 4 years ago
parent
commit
1866617070

+ 6 - 5
examples/js/exporters/ColladaExporter.js

@@ -201,9 +201,10 @@ THREE.ColladaExporter.prototype = {
 
 				// convert the geometry to bufferGeometry if it isn't already
 				var bufferGeometry = g;
-				if ( bufferGeometry instanceof THREE.Geometry ) {
 
-					bufferGeometry = ( new THREE.BufferGeometry() ).fromGeometry( bufferGeometry );
+				if ( bufferGeometry.isBufferGeometry !== true ) {
+
+					throw new Error( 'THREE.ColladaExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 				}
 
@@ -363,11 +364,11 @@ THREE.ColladaExporter.prototype = {
 
 				var type = 'phong';
 
-				if ( m instanceof THREE.MeshLambertMaterial ) {
+				if ( m.isMeshLambertMaterial === true ) {
 
 					type = 'lambert';
 
-				} else if ( m instanceof THREE.MeshBasicMaterial ) {
+				} else if ( m.isMeshBasicMaterial === true ) {
 
 					type = 'constant';
 
@@ -543,7 +544,7 @@ THREE.ColladaExporter.prototype = {
 
 			node += getTransform( o );
 
-			if ( o instanceof THREE.Mesh && o.geometry != null ) {
+			if ( o.isMesh === true && o.geometry !== null ) {
 
 				// function returns the id associated with the mesh and a "BufferGeometry" version
 				// of the geometry in case it's not a geometry.

+ 2 - 3
examples/js/exporters/GLTFExporter.js

@@ -1239,10 +1239,9 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			if ( ! geometry.isBufferGeometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				console.warn( 'GLTFExporter: Exporting THREE.Geometry will increase file size. Use THREE.BufferGeometry instead.' );
-				geometry = new THREE.BufferGeometry().setFromObject( mesh );
+				throw new Error( 'THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 

+ 111 - 135
examples/js/exporters/OBJExporter.js

@@ -29,129 +29,121 @@ THREE.OBJExporter.prototype = {
 
 			var normalMatrixWorld = new THREE.Matrix3();
 
-			if ( geometry instanceof THREE.Geometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				geometry = new THREE.BufferGeometry().setFromObject( mesh );
+				throw new Error( 'THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 
-			if ( geometry instanceof THREE.BufferGeometry ) {
+			// shortcuts
+			var vertices = geometry.getAttribute( 'position' );
+			var normals = geometry.getAttribute( 'normal' );
+			var uvs = geometry.getAttribute( 'uv' );
+			var indices = geometry.getIndex();
 
-				// shortcuts
-				var vertices = geometry.getAttribute( 'position' );
-				var normals = geometry.getAttribute( 'normal' );
-				var uvs = geometry.getAttribute( 'uv' );
-				var indices = geometry.getIndex();
+			// name of the mesh object
+			output += 'o ' + mesh.name + '\n';
 
-				// name of the mesh object
-				output += 'o ' + mesh.name + '\n';
+			// name of the mesh material
+			if ( mesh.material && mesh.material.name ) {
 
-				// name of the mesh material
-				if ( mesh.material && mesh.material.name ) {
+				output += 'usemtl ' + mesh.material.name + '\n';
 
-					output += 'usemtl ' + mesh.material.name + '\n';
-
-				}
-
-				// vertices
+			}
 
-				if ( vertices !== undefined ) {
+			// vertices
 
-					for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
+			if ( vertices !== undefined ) {
 
-						vertex.x = vertices.getX( i );
-						vertex.y = vertices.getY( i );
-						vertex.z = vertices.getZ( i );
+				for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
 
-						// transform the vertex to world space
-						vertex.applyMatrix4( mesh.matrixWorld );
+					vertex.x = vertices.getX( i );
+					vertex.y = vertices.getY( i );
+					vertex.z = vertices.getZ( i );
 
-						// transform the vertex to export format
-						output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
+					// transform the vertex to world space
+					vertex.applyMatrix4( mesh.matrixWorld );
 
-					}
+					// transform the vertex to export format
+					output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
 
 				}
 
-				// uvs
+			}
 
-				if ( uvs !== undefined ) {
+			// uvs
 
-					for ( i = 0, l = uvs.count; i < l; i ++, nbVertexUvs ++ ) {
+			if ( uvs !== undefined ) {
 
-						uv.x = uvs.getX( i );
-						uv.y = uvs.getY( i );
+				for ( i = 0, l = uvs.count; i < l; i ++, nbVertexUvs ++ ) {
 
-						// transform the uv to export format
-						output += 'vt ' + uv.x + ' ' + uv.y + '\n';
+					uv.x = uvs.getX( i );
+					uv.y = uvs.getY( i );
 
-					}
+					// transform the uv to export format
+					output += 'vt ' + uv.x + ' ' + uv.y + '\n';
 
 				}
 
-				// normals
+			}
 
-				if ( normals !== undefined ) {
+			// normals
 
-					normalMatrixWorld.getNormalMatrix( mesh.matrixWorld );
+			if ( normals !== undefined ) {
 
-					for ( i = 0, l = normals.count; i < l; i ++, nbNormals ++ ) {
+				normalMatrixWorld.getNormalMatrix( mesh.matrixWorld );
 
-						normal.x = normals.getX( i );
-						normal.y = normals.getY( i );
-						normal.z = normals.getZ( i );
+				for ( i = 0, l = normals.count; i < l; i ++, nbNormals ++ ) {
 
-						// transform the normal to world space
-						normal.applyMatrix3( normalMatrixWorld ).normalize();
+					normal.x = normals.getX( i );
+					normal.y = normals.getY( i );
+					normal.z = normals.getZ( i );
 
-						// transform the normal to export format
-						output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
+					// transform the normal to world space
+					normal.applyMatrix3( normalMatrixWorld ).normalize();
 
-					}
+					// transform the normal to export format
+					output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
 
 				}
 
-				// faces
-
-				if ( indices !== null ) {
+			}
 
-					for ( i = 0, l = indices.count; i < l; i += 3 ) {
+			// faces
 
-						for ( m = 0; m < 3; m ++ ) {
+			if ( indices !== null ) {
 
-							j = indices.getX( i + m ) + 1;
+				for ( i = 0, l = indices.count; i < l; i += 3 ) {
 
-							face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
+					for ( m = 0; m < 3; m ++ ) {
 
-						}
+						j = indices.getX( i + m ) + 1;
 
-						// transform the face to export format
-						output += 'f ' + face.join( ' ' ) + '\n';
+						face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
 
 					}
 
-				} else {
+					// transform the face to export format
+					output += 'f ' + face.join( ' ' ) + '\n';
 
-					for ( i = 0, l = vertices.count; i < l; i += 3 ) {
+				}
 
-						for ( m = 0; m < 3; m ++ ) {
+			} else {
 
-							j = i + m + 1;
+				for ( i = 0, l = vertices.count; i < l; i += 3 ) {
 
-							face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
+					for ( m = 0; m < 3; m ++ ) {
 
-						}
+						j = i + m + 1;
 
-						// transform the face to export format
-						output += 'f ' + face.join( ' ' ) + '\n';
+						face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
 
 					}
 
-				}
-
-			} else {
+					// transform the face to export format
+					output += 'f ' + face.join( ' ' ) + '\n';
 
-				console.warn( 'THREE.OBJExporter.parseMesh(): geometry type unsupported', geometry );
+				}
 
 			}
 
@@ -169,65 +161,57 @@ THREE.OBJExporter.prototype = {
 			var geometry = line.geometry;
 			var type = line.type;
 
-			if ( geometry instanceof THREE.Geometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				geometry = new THREE.BufferGeometry().setFromObject( line );
+				throw new Error( 'THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 
-			if ( geometry instanceof THREE.BufferGeometry ) {
-
-				// shortcuts
-				var vertices = geometry.getAttribute( 'position' );
+			// shortcuts
+			var vertices = geometry.getAttribute( 'position' );
 
-				// name of the line object
-				output += 'o ' + line.name + '\n';
+			// name of the line object
+			output += 'o ' + line.name + '\n';
 
-				if ( vertices !== undefined ) {
+			if ( vertices !== undefined ) {
 
-					for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
+				for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
 
-						vertex.x = vertices.getX( i );
-						vertex.y = vertices.getY( i );
-						vertex.z = vertices.getZ( i );
+					vertex.x = vertices.getX( i );
+					vertex.y = vertices.getY( i );
+					vertex.z = vertices.getZ( i );
 
-						// transform the vertex to world space
-						vertex.applyMatrix4( line.matrixWorld );
+					// transform the vertex to world space
+					vertex.applyMatrix4( line.matrixWorld );
 
-						// transform the vertex to export format
-						output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
-
-					}
+					// transform the vertex to export format
+					output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
 
 				}
 
-				if ( type === 'Line' ) {
-
-					output += 'l ';
+			}
 
-					for ( j = 1, l = vertices.count; j <= l; j ++ ) {
+			if ( type === 'Line' ) {
 
-						output += ( indexVertex + j ) + ' ';
+				output += 'l ';
 
-					}
+				for ( j = 1, l = vertices.count; j <= l; j ++ ) {
 
-					output += '\n';
+					output += ( indexVertex + j ) + ' ';
 
 				}
 
-				if ( type === 'LineSegments' ) {
-
-					for ( j = 1, k = j + 1, l = vertices.count; j < l; j += 2, k = j + 1 ) {
+				output += '\n';
 
-						output += 'l ' + ( indexVertex + j ) + ' ' + ( indexVertex + k ) + '\n';
+			}
 
-					}
+			if ( type === 'LineSegments' ) {
 
-				}
+				for ( j = 1, k = j + 1, l = vertices.count; j < l; j += 2, k = j + 1 ) {
 
-			} else {
+					output += 'l ' + ( indexVertex + j ) + ' ' + ( indexVertex + k ) + '\n';
 
-				console.warn( 'THREE.OBJExporter.parseLine(): geometry type unsupported', geometry );
+				}
 
 			}
 
@@ -242,58 +226,50 @@ THREE.OBJExporter.prototype = {
 
 			var geometry = points.geometry;
 
-			if ( geometry instanceof THREE.Geometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				geometry = new THREE.BufferGeometry().setFromObject( points );
+				throw new Error( 'THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 
-			if ( geometry instanceof THREE.BufferGeometry ) {
-
-				var vertices = geometry.getAttribute( 'position' );
-				var colors = geometry.getAttribute( 'color' );
-
-				output += 'o ' + points.name + '\n';
-
-				if ( vertices !== undefined ) {
+			var vertices = geometry.getAttribute( 'position' );
+			var colors = geometry.getAttribute( 'color' );
 
-					for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
+			output += 'o ' + points.name + '\n';
 
-						vertex.fromBufferAttribute( vertices, i );
-						vertex.applyMatrix4( points.matrixWorld );
+			if ( vertices !== undefined ) {
 
-						output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z;
+				for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
 
-						if ( colors !== undefined ) {
+					vertex.fromBufferAttribute( vertices, i );
+					vertex.applyMatrix4( points.matrixWorld );
 
-							color.fromBufferAttribute( colors, i );
+					output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z;
 
-							output += ' ' + color.r + ' ' + color.g + ' ' + color.b;
+					if ( colors !== undefined ) {
 
-						}
+						color.fromBufferAttribute( colors, i );
 
-						output += '\n';
+						output += ' ' + color.r + ' ' + color.g + ' ' + color.b;
 
 					}
 
-				}
-
-				output += 'p ';
-
-				for ( j = 1, l = vertices.count; j <= l; j ++ ) {
-
-					output += ( indexVertex + j ) + ' ';
+					output += '\n';
 
 				}
 
-				output += '\n';
+			}
 
-			} else {
+			output += 'p ';
+
+			for ( j = 1, l = vertices.count; j <= l; j ++ ) {
 
-				console.warn( 'THREE.OBJExporter.parsePoints(): geometry type unsupported', geometry );
+				output += ( indexVertex + j ) + ' ';
 
 			}
 
+			output += '\n';
+
 			// update index
 			indexVertex += nbVertex;
 
@@ -301,19 +277,19 @@ THREE.OBJExporter.prototype = {
 
 		object.traverse( function ( child ) {
 
-			if ( child instanceof THREE.Mesh ) {
+			if ( child.isMesh === true ) {
 
 				parseMesh( child );
 
 			}
 
-			if ( child instanceof THREE.Line ) {
+			if ( child.isLine === true ) {
 
 				parseLine( child );
 
 			}
 
-			if ( child instanceof THREE.Points ) {
+			if ( child.isPoints === true ) {
 
 				parsePoints( child );
 

+ 19 - 30
examples/js/exporters/PLYExporter.js

@@ -37,19 +37,15 @@ THREE.PLYExporter.prototype = {
 					var mesh = child;
 					var geometry = mesh.geometry;
 
-					if ( geometry.isGeometry === true ) {
+					if ( geometry.isBufferGeometry !== true ) {
 
-						geometry = geomToBufferGeom.get( geometry );
+						throw new Error( 'THREE.PLYExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 					}
 
-					if ( geometry.isBufferGeometry === true ) {
+					if ( geometry.hasAttribute( 'position' ) === true ) {
 
-						if ( geometry.hasAttribute( 'position' ) === true ) {
-
-							cb( mesh, geometry );
-
-						}
+						cb( mesh, geometry );
 
 					}
 
@@ -69,7 +65,6 @@ THREE.PLYExporter.prototype = {
 		options = Object.assign( defaultOptions, options );
 
 		var excludeAttributes = options.excludeAttributes;
-		var geomToBufferGeom = new WeakMap();
 		var includeNormals = false;
 		var includeColors = false;
 		var includeUVs = false;
@@ -85,38 +80,32 @@ THREE.PLYExporter.prototype = {
 				var mesh = child;
 				var geometry = mesh.geometry;
 
-				if ( geometry.isGeometry === true ) {
+				if ( geometry.isBufferGeometry !== true ) {
 
-					var bufferGeometry = geomToBufferGeom.get( geometry ) || new THREE.BufferGeometry().setFromObject( mesh );
-					geomToBufferGeom.set( geometry, bufferGeometry );
-					geometry = bufferGeometry;
+					throw new Error( 'THREE.PLYExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 				}
 
-				if ( geometry.isBufferGeometry === true ) {
-
-					var vertices = geometry.getAttribute( 'position' );
-					var normals = geometry.getAttribute( 'normal' );
-					var uvs = geometry.getAttribute( 'uv' );
-					var colors = geometry.getAttribute( 'color' );
-					var indices = geometry.getIndex();
-
-					if ( vertices === undefined ) {
+				var vertices = geometry.getAttribute( 'position' );
+				var normals = geometry.getAttribute( 'normal' );
+				var uvs = geometry.getAttribute( 'uv' );
+				var colors = geometry.getAttribute( 'color' );
+				var indices = geometry.getIndex();
 
-						return;
+				if ( vertices === undefined ) {
 
-					}
+					return;
 
-					vertexCount += vertices.count;
-					faceCount += indices ? indices.count / 3 : vertices.count / 3;
+				}
 
-					if ( normals !== undefined ) includeNormals = true;
+				vertexCount += vertices.count;
+				faceCount += indices ? indices.count / 3 : vertices.count / 3;
 
-					if ( uvs !== undefined ) includeUVs = true;
+				if ( normals !== undefined ) includeNormals = true;
 
-					if ( colors !== undefined ) includeColors = true;
+				if ( uvs !== undefined ) includeUVs = true;
 
-				}
+				if ( colors !== undefined ) includeColors = true;
 
 			}
 

+ 2 - 2
examples/js/exporters/STLExporter.js

@@ -30,9 +30,9 @@ THREE.STLExporter.prototype = {
 
 				var geometry = object.geometry;
 
-				if ( geometry.isGeometry ) {
+				if ( geometry.isBufferGeometry !== true ) {
 
-					geometry = new THREE.BufferGeometry().fromGeometry( geometry );
+					throw new Error( 'THREE.STLExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 				}
 

+ 7 - 10
examples/jsm/exporters/ColladaExporter.js

@@ -1,12 +1,8 @@
 import {
-	BufferGeometry,
 	Color,
 	DoubleSide,
-	Geometry,
 	Matrix4,
-	Mesh,
-	MeshBasicMaterial,
-	MeshLambertMaterial
+	MeshBasicMaterial
 } from '../../../build/three.module.js';
 
 /**
@@ -212,9 +208,10 @@ ColladaExporter.prototype = {
 
 				// convert the geometry to bufferGeometry if it isn't already
 				var bufferGeometry = g;
-				if ( bufferGeometry instanceof Geometry ) {
 
-					bufferGeometry = ( new BufferGeometry() ).fromGeometry( bufferGeometry );
+				if ( bufferGeometry.isBufferGeometry !== true ) {
+
+					throw new Error( 'THREE.ColladaExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 				}
 
@@ -374,11 +371,11 @@ ColladaExporter.prototype = {
 
 				var type = 'phong';
 
-				if ( m instanceof MeshLambertMaterial ) {
+				if ( m.isMeshLambertMaterial === true ) {
 
 					type = 'lambert';
 
-				} else if ( m instanceof MeshBasicMaterial ) {
+				} else if ( m.isMeshBasicMaterial === true ) {
 
 					type = 'constant';
 
@@ -554,7 +551,7 @@ ColladaExporter.prototype = {
 
 			node += getTransform( o );
 
-			if ( o instanceof Mesh && o.geometry != null ) {
+			if ( o.isMesh === true && o.geometry !== null ) {
 
 				// function returns the id associated with the mesh and a "BufferGeometry" version
 				// of the geometry in case it's not a geometry.

+ 1 - 5
examples/jsm/exporters/DRACOExporter.js

@@ -1,7 +1,3 @@
-import {
-	BufferGeometry
-} from '../../../build/three.module.js';
-
 /**
  * Export draco compressed files from threejs geometry objects.
  *
@@ -64,7 +60,7 @@ DRACOExporter.prototype = {
 
 		if ( geometry.isBufferGeometry !== true ) {
 
-			throw new Error( 'THREE.DRACOExporter.parse(geometry, options): geometry is not a BufferGeometry instance.' );
+			throw new Error( 'THREE.DRACOExporter.parse(geometry, options): geometry is not a THREE.BufferGeometry instance.' );
 
 		}
 

+ 3 - 5
examples/jsm/exporters/GLTFExporter.js

@@ -1,6 +1,5 @@
 import {
 	BufferAttribute,
-	BufferGeometry,
 	ClampToEdgeWrapping,
 	DoubleSide,
 	InterpolateDiscrete,
@@ -657,7 +656,7 @@ GLTFExporter.prototype = {
 		/**
 		 * Process attribute to generate an accessor
 		 * @param  {BufferAttribute} attribute Attribute to process
-		 * @param  {BufferGeometry} geometry (Optional) Geometry used for truncated draw range
+		 * @param  {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
 		 * @param  {Integer} start (Optional)
 		 * @param  {Integer} count (Optional)
 		 * @return {Integer}           Index of the processed accessor on the "accessors" array
@@ -1263,10 +1262,9 @@ GLTFExporter.prototype = {
 
 			}
 
-			if ( ! geometry.isBufferGeometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				console.warn( 'GLTFExporter: Exporting THREE.Geometry will increase file size. Use BufferGeometry instead.' );
-				geometry = new BufferGeometry().setFromObject( mesh );
+				throw new Error( 'THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 

+ 111 - 140
examples/jsm/exporters/OBJExporter.js

@@ -1,11 +1,6 @@
 import {
-	BufferGeometry,
 	Color,
-	Geometry,
-	Line,
 	Matrix3,
-	Mesh,
-	Points,
 	Vector2,
 	Vector3
 } from '../../../build/three.module.js';
@@ -41,129 +36,121 @@ OBJExporter.prototype = {
 
 			var normalMatrixWorld = new Matrix3();
 
-			if ( geometry instanceof Geometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				geometry = new BufferGeometry().setFromObject( mesh );
+				throw new Error( 'THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 
-			if ( geometry instanceof BufferGeometry ) {
+			// shortcuts
+			var vertices = geometry.getAttribute( 'position' );
+			var normals = geometry.getAttribute( 'normal' );
+			var uvs = geometry.getAttribute( 'uv' );
+			var indices = geometry.getIndex();
 
-				// shortcuts
-				var vertices = geometry.getAttribute( 'position' );
-				var normals = geometry.getAttribute( 'normal' );
-				var uvs = geometry.getAttribute( 'uv' );
-				var indices = geometry.getIndex();
+			// name of the mesh object
+			output += 'o ' + mesh.name + '\n';
 
-				// name of the mesh object
-				output += 'o ' + mesh.name + '\n';
+			// name of the mesh material
+			if ( mesh.material && mesh.material.name ) {
 
-				// name of the mesh material
-				if ( mesh.material && mesh.material.name ) {
+				output += 'usemtl ' + mesh.material.name + '\n';
 
-					output += 'usemtl ' + mesh.material.name + '\n';
-
-				}
-
-				// vertices
+			}
 
-				if ( vertices !== undefined ) {
+			// vertices
 
-					for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
+			if ( vertices !== undefined ) {
 
-						vertex.x = vertices.getX( i );
-						vertex.y = vertices.getY( i );
-						vertex.z = vertices.getZ( i );
+				for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
 
-						// transform the vertex to world space
-						vertex.applyMatrix4( mesh.matrixWorld );
+					vertex.x = vertices.getX( i );
+					vertex.y = vertices.getY( i );
+					vertex.z = vertices.getZ( i );
 
-						// transform the vertex to export format
-						output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
+					// transform the vertex to world space
+					vertex.applyMatrix4( mesh.matrixWorld );
 
-					}
+					// transform the vertex to export format
+					output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
 
 				}
 
-				// uvs
+			}
 
-				if ( uvs !== undefined ) {
+			// uvs
 
-					for ( i = 0, l = uvs.count; i < l; i ++, nbVertexUvs ++ ) {
+			if ( uvs !== undefined ) {
 
-						uv.x = uvs.getX( i );
-						uv.y = uvs.getY( i );
+				for ( i = 0, l = uvs.count; i < l; i ++, nbVertexUvs ++ ) {
 
-						// transform the uv to export format
-						output += 'vt ' + uv.x + ' ' + uv.y + '\n';
+					uv.x = uvs.getX( i );
+					uv.y = uvs.getY( i );
 
-					}
+					// transform the uv to export format
+					output += 'vt ' + uv.x + ' ' + uv.y + '\n';
 
 				}
 
-				// normals
+			}
 
-				if ( normals !== undefined ) {
+			// normals
 
-					normalMatrixWorld.getNormalMatrix( mesh.matrixWorld );
+			if ( normals !== undefined ) {
 
-					for ( i = 0, l = normals.count; i < l; i ++, nbNormals ++ ) {
+				normalMatrixWorld.getNormalMatrix( mesh.matrixWorld );
 
-						normal.x = normals.getX( i );
-						normal.y = normals.getY( i );
-						normal.z = normals.getZ( i );
+				for ( i = 0, l = normals.count; i < l; i ++, nbNormals ++ ) {
 
-						// transform the normal to world space
-						normal.applyMatrix3( normalMatrixWorld ).normalize();
+					normal.x = normals.getX( i );
+					normal.y = normals.getY( i );
+					normal.z = normals.getZ( i );
 
-						// transform the normal to export format
-						output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
+					// transform the normal to world space
+					normal.applyMatrix3( normalMatrixWorld ).normalize();
 
-					}
+					// transform the normal to export format
+					output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
 
 				}
 
-				// faces
-
-				if ( indices !== null ) {
+			}
 
-					for ( i = 0, l = indices.count; i < l; i += 3 ) {
+			// faces
 
-						for ( m = 0; m < 3; m ++ ) {
+			if ( indices !== null ) {
 
-							j = indices.getX( i + m ) + 1;
+				for ( i = 0, l = indices.count; i < l; i += 3 ) {
 
-							face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
+					for ( m = 0; m < 3; m ++ ) {
 
-						}
+						j = indices.getX( i + m ) + 1;
 
-						// transform the face to export format
-						output += 'f ' + face.join( ' ' ) + '\n';
+						face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
 
 					}
 
-				} else {
+					// transform the face to export format
+					output += 'f ' + face.join( ' ' ) + '\n';
 
-					for ( i = 0, l = vertices.count; i < l; i += 3 ) {
+				}
 
-						for ( m = 0; m < 3; m ++ ) {
+			} else {
 
-							j = i + m + 1;
+				for ( i = 0, l = vertices.count; i < l; i += 3 ) {
 
-							face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
+					for ( m = 0; m < 3; m ++ ) {
 
-						}
+						j = i + m + 1;
 
-						// transform the face to export format
-						output += 'f ' + face.join( ' ' ) + '\n';
+						face[ m ] = ( indexVertex + j ) + ( normals || uvs ? '/' + ( uvs ? ( indexVertexUvs + j ) : '' ) + ( normals ? '/' + ( indexNormals + j ) : '' ) : '' );
 
 					}
 
-				}
-
-			} else {
+					// transform the face to export format
+					output += 'f ' + face.join( ' ' ) + '\n';
 
-				console.warn( 'THREE.OBJExporter.parseMesh(): geometry type unsupported', geometry );
+				}
 
 			}
 
@@ -181,65 +168,57 @@ OBJExporter.prototype = {
 			var geometry = line.geometry;
 			var type = line.type;
 
-			if ( geometry instanceof Geometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				geometry = new BufferGeometry().setFromObject( line );
+				throw new Error( 'THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 
-			if ( geometry instanceof BufferGeometry ) {
-
-				// shortcuts
-				var vertices = geometry.getAttribute( 'position' );
+			// shortcuts
+			var vertices = geometry.getAttribute( 'position' );
 
-				// name of the line object
-				output += 'o ' + line.name + '\n';
+			// name of the line object
+			output += 'o ' + line.name + '\n';
 
-				if ( vertices !== undefined ) {
+			if ( vertices !== undefined ) {
 
-					for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
+				for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
 
-						vertex.x = vertices.getX( i );
-						vertex.y = vertices.getY( i );
-						vertex.z = vertices.getZ( i );
+					vertex.x = vertices.getX( i );
+					vertex.y = vertices.getY( i );
+					vertex.z = vertices.getZ( i );
 
-						// transform the vertex to world space
-						vertex.applyMatrix4( line.matrixWorld );
+					// transform the vertex to world space
+					vertex.applyMatrix4( line.matrixWorld );
 
-						// transform the vertex to export format
-						output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
-
-					}
+					// transform the vertex to export format
+					output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';
 
 				}
 
-				if ( type === 'Line' ) {
-
-					output += 'l ';
+			}
 
-					for ( j = 1, l = vertices.count; j <= l; j ++ ) {
+			if ( type === 'Line' ) {
 
-						output += ( indexVertex + j ) + ' ';
+				output += 'l ';
 
-					}
+				for ( j = 1, l = vertices.count; j <= l; j ++ ) {
 
-					output += '\n';
+					output += ( indexVertex + j ) + ' ';
 
 				}
 
-				if ( type === 'LineSegments' ) {
-
-					for ( j = 1, k = j + 1, l = vertices.count; j < l; j += 2, k = j + 1 ) {
+				output += '\n';
 
-						output += 'l ' + ( indexVertex + j ) + ' ' + ( indexVertex + k ) + '\n';
+			}
 
-					}
+			if ( type === 'LineSegments' ) {
 
-				}
+				for ( j = 1, k = j + 1, l = vertices.count; j < l; j += 2, k = j + 1 ) {
 
-			} else {
+					output += 'l ' + ( indexVertex + j ) + ' ' + ( indexVertex + k ) + '\n';
 
-				console.warn( 'THREE.OBJExporter.parseLine(): geometry type unsupported', geometry );
+				}
 
 			}
 
@@ -254,58 +233,50 @@ OBJExporter.prototype = {
 
 			var geometry = points.geometry;
 
-			if ( geometry instanceof Geometry ) {
+			if ( geometry.isBufferGeometry !== true ) {
 
-				geometry = new BufferGeometry().setFromObject( points );
+				throw new Error( 'THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 			}
 
-			if ( geometry instanceof BufferGeometry ) {
-
-				var vertices = geometry.getAttribute( 'position' );
-				var colors = geometry.getAttribute( 'color' );
-
-				output += 'o ' + points.name + '\n';
-
-				if ( vertices !== undefined ) {
+			var vertices = geometry.getAttribute( 'position' );
+			var colors = geometry.getAttribute( 'color' );
 
-					for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
+			output += 'o ' + points.name + '\n';
 
-						vertex.fromBufferAttribute( vertices, i );
-						vertex.applyMatrix4( points.matrixWorld );
+			if ( vertices !== undefined ) {
 
-						output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z;
+				for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
 
-						if ( colors !== undefined ) {
+					vertex.fromBufferAttribute( vertices, i );
+					vertex.applyMatrix4( points.matrixWorld );
 
-							color.fromBufferAttribute( colors, i );
+					output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z;
 
-							output += ' ' + color.r + ' ' + color.g + ' ' + color.b;
+					if ( colors !== undefined ) {
 
-						}
+						color.fromBufferAttribute( colors, i );
 
-						output += '\n';
+						output += ' ' + color.r + ' ' + color.g + ' ' + color.b;
 
 					}
 
-				}
-
-				output += 'p ';
-
-				for ( j = 1, l = vertices.count; j <= l; j ++ ) {
-
-					output += ( indexVertex + j ) + ' ';
+					output += '\n';
 
 				}
 
-				output += '\n';
+			}
 
-			} else {
+			output += 'p ';
+
+			for ( j = 1, l = vertices.count; j <= l; j ++ ) {
 
-				console.warn( 'THREE.OBJExporter.parsePoints(): geometry type unsupported', geometry );
+				output += ( indexVertex + j ) + ' ';
 
 			}
 
+			output += '\n';
+
 			// update index
 			indexVertex += nbVertex;
 
@@ -313,19 +284,19 @@ OBJExporter.prototype = {
 
 		object.traverse( function ( child ) {
 
-			if ( child instanceof Mesh ) {
+			if ( child.isMesh === true ) {
 
 				parseMesh( child );
 
 			}
 
-			if ( child instanceof Line ) {
+			if ( child.isLine === true ) {
 
 				parseLine( child );
 
 			}
 
-			if ( child instanceof Points ) {
+			if ( child.isPoints === true ) {
 
 				parsePoints( child );
 

+ 19 - 31
examples/jsm/exporters/PLYExporter.js

@@ -1,5 +1,4 @@
 import {
-	BufferGeometry,
 	Matrix3,
 	Vector3
 } from '../../../build/three.module.js';
@@ -43,19 +42,15 @@ PLYExporter.prototype = {
 					var mesh = child;
 					var geometry = mesh.geometry;
 
-					if ( geometry.isGeometry === true ) {
+					if ( geometry.isBufferGeometry !== true ) {
 
-						geometry = geomToBufferGeom.get( geometry );
+						throw new Error( 'THREE.PLYExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 					}
 
-					if ( geometry.isBufferGeometry === true ) {
+					if ( geometry.hasAttribute( 'position' ) === true ) {
 
-						if ( geometry.hasAttribute( 'position' ) === true ) {
-
-							cb( mesh, geometry );
-
-						}
+						cb( mesh, geometry );
 
 					}
 
@@ -75,7 +70,6 @@ PLYExporter.prototype = {
 		options = Object.assign( defaultOptions, options );
 
 		var excludeAttributes = options.excludeAttributes;
-		var geomToBufferGeom = new WeakMap();
 		var includeNormals = false;
 		var includeColors = false;
 		var includeUVs = false;
@@ -91,38 +85,32 @@ PLYExporter.prototype = {
 				var mesh = child;
 				var geometry = mesh.geometry;
 
-				if ( geometry.isGeometry === true ) {
+				if ( geometry.isBufferGeometry !== true ) {
 
-					var bufferGeometry = geomToBufferGeom.get( geometry ) || new BufferGeometry().setFromObject( mesh );
-					geomToBufferGeom.set( geometry, bufferGeometry );
-					geometry = bufferGeometry;
+					throw new Error( 'THREE.PLYExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 				}
 
-				if ( geometry.isBufferGeometry === true ) {
-
-					var vertices = geometry.getAttribute( 'position' );
-					var normals = geometry.getAttribute( 'normal' );
-					var uvs = geometry.getAttribute( 'uv' );
-					var colors = geometry.getAttribute( 'color' );
-					var indices = geometry.getIndex();
-
-					if ( vertices === undefined ) {
+				var vertices = geometry.getAttribute( 'position' );
+				var normals = geometry.getAttribute( 'normal' );
+				var uvs = geometry.getAttribute( 'uv' );
+				var colors = geometry.getAttribute( 'color' );
+				var indices = geometry.getIndex();
 
-						return;
+				if ( vertices === undefined ) {
 
-					}
+					return;
 
-					vertexCount += vertices.count;
-					faceCount += indices ? indices.count / 3 : vertices.count / 3;
+				}
 
-					if ( normals !== undefined ) includeNormals = true;
+				vertexCount += vertices.count;
+				faceCount += indices ? indices.count / 3 : vertices.count / 3;
 
-					if ( uvs !== undefined ) includeUVs = true;
+				if ( normals !== undefined ) includeNormals = true;
 
-					if ( colors !== undefined ) includeColors = true;
+				if ( uvs !== undefined ) includeUVs = true;
 
-				}
+				if ( colors !== undefined ) includeColors = true;
 
 			}
 

+ 2 - 3
examples/jsm/exporters/STLExporter.js

@@ -1,5 +1,4 @@
 import {
-	BufferGeometry,
 	Vector3
 } from '../../../build/three.module.js';
 
@@ -35,9 +34,9 @@ STLExporter.prototype = {
 
 				var geometry = object.geometry;
 
-				if ( geometry.isGeometry ) {
+				if ( geometry.isBufferGeometry !== true ) {
 
-					geometry = new BufferGeometry().fromGeometry( geometry );
+					throw new Error( 'THREE.STLExporter: Geometry is not of type THREE.BufferGeometry.' );
 
 				}
 

+ 6 - 6
utils/modularize.js

@@ -34,13 +34,13 @@ var files = [
 	{ path: 'effects/PeppersGhostEffect.js', dependencies: [], ignoreList: [] },
 	{ path: 'effects/StereoEffect.js', dependencies: [], ignoreList: [] },
 
-	{ path: 'exporters/ColladaExporter.js', dependencies: [], ignoreList: [] },
-	{ path: 'exporters/DRACOExporter.js', dependencies: [], ignoreList: [ 'Geometry' ] },
-	{ path: 'exporters/GLTFExporter.js', dependencies: [], ignoreList: [ 'AnimationClip', 'Camera', 'Geometry', 'Material', 'Mesh', 'Object3D', 'Scenes', 'ShaderMaterial' ] },
+	{ path: 'exporters/ColladaExporter.js', dependencies: [], ignoreList: [ 'BufferGeometry' ] },
+	{ path: 'exporters/DRACOExporter.js', dependencies: [], ignoreList: [ 'Geometry', 'BufferGeometry' ] },
+	{ path: 'exporters/GLTFExporter.js', dependencies: [], ignoreList: [ 'AnimationClip', 'Camera', 'Geometry', 'Material', 'Mesh', 'Object3D', 'Scenes', 'ShaderMaterial', 'BufferGeometry' ] },
 	{ path: 'exporters/MMDExporter.js', dependencies: [ { name: 'MMDParser', path: 'libs/mmdparser.module.js' } ], ignoreList: [] },
-	{ path: 'exporters/OBJExporter.js', dependencies: [], ignoreList: [] },
-	{ path: 'exporters/PLYExporter.js', dependencies: [], ignoreList: [] },
-	{ path: 'exporters/STLExporter.js', dependencies: [], ignoreList: [] },
+	{ path: 'exporters/OBJExporter.js', dependencies: [], ignoreList: [ 'BufferGeometry' ] },
+	{ path: 'exporters/PLYExporter.js', dependencies: [], ignoreList: [ 'BufferGeometry' ] },
+	{ path: 'exporters/STLExporter.js', dependencies: [], ignoreList: [ 'BufferGeometry' ] },
 
 	{ path: 'geometries/BoxLineGeometry.js', dependencies: [], ignoreList: [] },
 	{ path: 'geometries/ConvexGeometry.js', dependencies: [ { name: 'ConvexHull', path: 'math/ConvexHull.js' } ], ignoreList: [] },