Przeglądaj źródła

EdgeSplitModifier: Remove Geometry support.

Mugen87 4 lat temu
rodzic
commit
44194e0729

+ 10 - 9
examples/js/modifiers/EdgeSplitModifier.js

@@ -153,36 +153,37 @@ THREE.EdgeSplitModifier = function () {
 
 	this.modify = function ( geometry, cutOffAngle, tryKeepNormals = true ) {
 
-		const wasNotBufferGeometry = geometry.isBufferGeometry === undefined;
-		if ( ! geometry.isBufferGeometry ) {
+		if ( geometry.isGeometry === true ) {
 
-			geometry = new THREE.BufferGeometry().fromGeometry( geometry );
+			console.error( 'THREE.EdgeSplitModifier no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
+			return;
 
 		}
 
-
 		let hadNormals = false;
 		oldNormals = null;
+
 		if ( geometry.attributes.normal ) {
 
 			hadNormals = true;
 
-			if ( wasNotBufferGeometry === false )
-				geometry = geometry.clone();
+			geometry = geometry.clone();
+
+			if ( tryKeepNormals === true && geometry.index !== null ) {
 
-			if ( tryKeepNormals && geometry.index )
 				oldNormals = geometry.attributes.normal.array;
 
+			}
+
 			geometry.deleteAttribute( 'normal' );
 
 		}
 
-
 		if ( geometry.index == null ) {
 
 			if ( THREE.BufferGeometryUtils === undefined ) {
 
-			 	throw 'THREE.EdgeSplitModifier relies on THREE.BufferGeometryUtils';
+				throw 'THREE.EdgeSplitModifier relies on THREE.BufferGeometryUtils';
 
 			}
 

+ 10 - 9
examples/jsm/modifiers/EdgeSplitModifier.js

@@ -160,36 +160,37 @@ var EdgeSplitModifier = function () {
 
 	this.modify = function ( geometry, cutOffAngle, tryKeepNormals = true ) {
 
-		const wasNotBufferGeometry = geometry.isBufferGeometry === undefined;
-		if ( ! geometry.isBufferGeometry ) {
+		if ( geometry.isGeometry === true ) {
 
-			geometry = new BufferGeometry().fromGeometry( geometry );
+			console.error( 'THREE.EdgeSplitModifier no longer supports THREE.Geometry. Use BufferGeometry instead.' );
+			return;
 
 		}
 
-
 		let hadNormals = false;
 		oldNormals = null;
+
 		if ( geometry.attributes.normal ) {
 
 			hadNormals = true;
 
-			if ( wasNotBufferGeometry === false )
-				geometry = geometry.clone();
+			geometry = geometry.clone();
+
+			if ( tryKeepNormals === true && geometry.index !== null ) {
 
-			if ( tryKeepNormals && geometry.index )
 				oldNormals = geometry.attributes.normal.array;
 
+			}
+
 			geometry.deleteAttribute( 'normal' );
 
 		}
 
-
 		if ( geometry.index == null ) {
 
 			if ( BufferGeometryUtils === undefined ) {
 
-			 	throw 'THREE.EdgeSplitModifier relies on BufferGeometryUtils';
+				throw 'THREE.EdgeSplitModifier relies on BufferGeometryUtils';
 
 			}
 

+ 1 - 1
utils/modularize.js

@@ -118,7 +118,7 @@ var files = [
 	{ path: 'misc/Volume.js', dependencies: [ { name: 'VolumeSlice', path: 'misc/VolumeSlice.js' } ], ignoreList: [] },
 	{ path: 'misc/VolumeSlice.js', dependencies: [], ignoreList: [] },
 
-	{ path: 'modifiers/EdgeSplitModifier.js', dependencies: [ { name: 'BufferGeometryUtils', path: 'utils/BufferGeometryUtils.js' } ], ignoreList: [] },
+	{ path: 'modifiers/EdgeSplitModifier.js', dependencies: [ { name: 'BufferGeometryUtils', path: 'utils/BufferGeometryUtils.js' } ], ignoreList: [ 'Geometry' ] },
 	{ path: 'modifiers/SimplifyModifier.js', dependencies: [], ignoreList: [] },
 	{ path: 'modifiers/SubdivisionModifier.js', dependencies: [], ignoreList: [] },
 	{ path: 'modifiers/TessellateModifier.js', dependencies: [], ignoreList: [] },