瀏覽代碼

Global: Fix some DeepScan issues. (#23351)

Michael Herzog 3 年之前
父節點
當前提交
fadb6ab1cf

+ 1 - 17
examples/jsm/helpers/VertexNormalsHelper.js

@@ -15,25 +15,9 @@ class VertexNormalsHelper extends LineSegments {
 
 	constructor( object, size = 1, color = 0xff0000 ) {
 
-		let nNormals = 0;
-
-		const objGeometry = object.geometry;
-
-		if ( objGeometry && objGeometry.isGeometry ) {
-
-			console.error( 'THREE.VertexNormalsHelper no longer supports Geometry. Use BufferGeometry instead.' );
-			return;
-
-		} else if ( objGeometry && objGeometry.isBufferGeometry ) {
-
-			nNormals = objGeometry.attributes.normal.count;
-
-		}
-
-		//
-
 		const geometry = new BufferGeometry();
 
+		const nNormals = object.geometry.attributes.normal.count;
 		const positions = new Float32BufferAttribute( nNormals * 2 * 3, 3 );
 
 		geometry.setAttribute( 'position', positions );

+ 1 - 13
examples/jsm/helpers/VertexTangentsHelper.js

@@ -13,21 +13,9 @@ class VertexTangentsHelper extends LineSegments {
 
 	constructor( object, size = 1, color = 0x00ffff ) {
 
-		const objGeometry = object.geometry;
-
-		if ( ! ( objGeometry && objGeometry.isBufferGeometry ) ) {
-
-			console.error( 'THREE.VertexTangentsHelper: geometry not an instance of THREE.BufferGeometry.', objGeometry );
-			return;
-
-		}
-
-		const nTangents = objGeometry.attributes.tangent.count;
-
-		//
-
 		const geometry = new BufferGeometry();
 
+		const nTangents = object.geometry.attributes.tangent.count;
 		const positions = new Float32BufferAttribute( nTangents * 2 * 3, 3 );
 
 		geometry.setAttribute( 'position', positions );

+ 1 - 10
examples/jsm/loaders/KTX2Loader.js

@@ -106,15 +106,6 @@ class KTX2Loader extends Loader {
 
 	}
 
-	dispose() {
-
-		this.workerPool.dispose();
-		if ( this.workerSourceURL ) URL.revokeObjectURL( this.workerSourceURL );
-
-		return this;
-
-	}
-
 	init() {
 
 		if ( ! this.transcoderPending ) {
@@ -270,8 +261,8 @@ class KTX2Loader extends Loader {
 
 	dispose() {
 
-		URL.revokeObjectURL( this.workerSourceURL );
 		this.workerPool.dispose();
+		if ( this.workerSourceURL ) URL.revokeObjectURL( this.workerSourceURL );
 
 		_activeLoaders --;
 

+ 1 - 38
examples/jsm/loaders/VTKLoader.js

@@ -890,44 +890,7 @@ class VTKLoader extends Loader {
 
 			// Main part
 			// Get Dom
-			var dom = null;
-
-			if ( window.DOMParser ) {
-
-				try {
-
-					dom = ( new DOMParser() ).parseFromString( stringFile, 'text/xml' );
-
-				} catch ( e ) {
-
-					dom = null;
-
-				}
-
-			} else if ( window.ActiveXObject ) {
-
-				try {
-
-					dom = new ActiveXObject( 'Microsoft.XMLDOM' ); // eslint-disable-line no-undef
-					dom.async = false;
-
-					if ( ! dom.loadXML( /* xml */ ) ) {
-
-						throw new Error( dom.parseError.reason + dom.parseError.srcText );
-
-					}
-
-				} catch ( e ) {
-
-					dom = null;
-
-				}
-
-			} else {
-
-				throw new Error( 'Cannot parse xml string!' );
-
-			}
+			var dom = new DOMParser().parseFromString( stringFile, 'application/xml' );
 
 			// Get the doc
 			var doc = dom.documentElement;

+ 1 - 1
examples/jsm/utils/BufferGeometryUtils.js

@@ -834,7 +834,7 @@ function computeMorphedAttributes( object ) {
 
 		}
 
-	} else if ( positionAttribute !== undefined ) {
+	} else {
 
 		// non-indexed buffer geometry
 

+ 2 - 2
src/core/Raycaster.js

@@ -33,13 +33,13 @@ class Raycaster {
 
 	setFromCamera( coords, camera ) {
 
-		if ( camera && camera.isPerspectiveCamera ) {
+		if ( camera.isPerspectiveCamera ) {
 
 			this.ray.origin.setFromMatrixPosition( camera.matrixWorld );
 			this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize();
 			this.camera = camera;
 
-		} else if ( camera && camera.isOrthographicCamera ) {
+		} else if ( camera.isOrthographicCamera ) {
 
 			this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera
 			this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );

+ 2 - 1
src/geometries/WireframeGeometry.js

@@ -124,7 +124,8 @@ function isUniqueEdge( start, end, edges ) {
 
 	} else {
 
-		edges.add( hash1, hash2 );
+		edges.add( hash1 );
+		edges.add( hash2 );
 		return true;
 
 	}

+ 1 - 1
src/helpers/SkeletonHelper.js

@@ -100,7 +100,7 @@ function getBoneList( object ) {
 
 	const boneList = [];
 
-	if ( object && object.isBone ) {
+	if ( object.isBone === true ) {
 
 		boneList.push( object );
 

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -1654,7 +1654,7 @@ function WebGLRenderer( parameters = {} ) {
 
 		}
 
-		if ( !! geometry && ( geometry.morphAttributes.position !== undefined || geometry.morphAttributes.normal !== undefined ) ) {
+		if ( geometry.morphAttributes.position !== undefined || geometry.morphAttributes.normal !== undefined ) {
 
 			morphtargets.update( object, geometry, material, program );
 

+ 1 - 1
src/renderers/webgl/WebGLBindingStates.js

@@ -354,7 +354,7 @@
 						const stride = data.stride;
 						const offset = geometryAttribute.offset;
 
-						if ( data && data.isInstancedInterleavedBuffer ) {
+						if ( data.isInstancedInterleavedBuffer ) {
 
 							for ( let i = 0; i < programAttribute.locationSize; i ++ ) {
 

+ 0 - 2
src/renderers/webgl/WebGLTextures.js

@@ -274,8 +274,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 		const renderTargetProperties = properties.get( renderTarget );
 		const textureProperties = properties.get( texture );
 
-		if ( ! renderTarget ) return;
-
 		if ( textureProperties.__webglTexture !== undefined ) {
 
 			_gl.deleteTexture( textureProperties.__webglTexture );

+ 1 - 1
test/benchmark/benchmark.js

@@ -24,7 +24,7 @@ BenchClass.prototype.newSuite = function ( name ) {
 
 BenchClass.prototype.display = function () {
 
-	for ( x of this.suites ) {
+	for ( var x of this.suites ) {
 
 		var s = new SuiteUI( x );
 		s.render();