Browse Source

GLTFExporter: Better handle point and line geometries.

Mugen87 5 years ago
parent
commit
8ea277018e
2 changed files with 10 additions and 16 deletions
  1. 5 8
      examples/js/exporters/GLTFExporter.js
  2. 5 8
      examples/jsm/exporters/GLTFExporter.js

+ 5 - 8
examples/js/exporters/GLTFExporter.js

@@ -1176,17 +1176,14 @@ THREE.GLTFExporter.prototype = {
 
 			} else {
 
-				if ( ! geometry.isBufferGeometry ) {
+				mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
 
-					console.warn( 'GLTFExporter: Exporting THREE.Geometry will increase file size. Use THREE.BufferGeometry instead.' );
+			}
 
-					var geometryTemp = new THREE.BufferGeometry();
-					geometryTemp.fromGeometry( geometry );
-					geometry = geometryTemp;
+			if ( ! geometry.isBufferGeometry ) {
 
-				}
-
-				mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
+				console.warn( 'GLTFExporter: Exporting THREE.Geometry will increase file size. Use THREE.BufferGeometry instead.' );
+				geometry = new THREE.BufferGeometry().setFromObject( mesh );
 
 			}
 

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

@@ -1198,17 +1198,14 @@ GLTFExporter.prototype = {
 
 			} else {
 
-				if ( ! geometry.isBufferGeometry ) {
+				mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
 
-					console.warn( 'GLTFExporter: Exporting THREE.Geometry will increase file size. Use BufferGeometry instead.' );
+			}
 
-					var geometryTemp = new BufferGeometry();
-					geometryTemp.fromGeometry( geometry );
-					geometry = geometryTemp;
+			if ( ! geometry.isBufferGeometry ) {
 
-				}
-
-				mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
+				console.warn( 'GLTFExporter: Exporting THREE.Geometry will increase file size. Use BufferGeometry instead.' );
+				geometry = new BufferGeometry().setFromObject( mesh );
 
 			}