Преглед на файлове

Core: Remove remaining DeepScan issues. (#23440)

* Core: Remove remaining DeepScan issues.

* BufferGeometry: Fix computeTangents().
Michael Herzog преди 3 години
родител
ревизия
f66f975188
променени са 5 файла, в които са добавени 16 реда и са изтрити 17 реда
  1. 2 2
      src/animation/PropertyBinding.js
  2. 2 2
      src/core/BufferGeometry.js
  3. 1 1
      src/extras/PMREMGenerator.js
  4. 5 6
      src/extras/core/ShapePath.js
  5. 6 6
      src/renderers/webgl/WebGLAttributes.js

+ 2 - 2
src/animation/PropertyBinding.js

@@ -149,7 +149,7 @@ class PropertyBinding {
 
 
 		const matches = _trackRe.exec( trackName );
 		const matches = _trackRe.exec( trackName );
 
 
-		if ( ! matches ) {
+		if ( matches === null ) {
 
 
 			throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName );
 			throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName );
 
 
@@ -195,7 +195,7 @@ class PropertyBinding {
 
 
 	static findNode( root, nodeName ) {
 	static findNode( root, nodeName ) {
 
 
-		if ( ! nodeName || nodeName === '' || nodeName === '.' || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) {
+		if ( nodeName === undefined || nodeName === '' || nodeName === '.' || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) {
 
 
 			return root;
 			return root;
 
 

+ 2 - 2
src/core/BufferGeometry.js

@@ -492,13 +492,13 @@ class BufferGeometry extends EventDispatcher {
 
 
 		const nVertices = positions.length / 3;
 		const nVertices = positions.length / 3;
 
 
-		if ( attributes.tangent === undefined ) {
+		if ( this.hasAttribute( 'tangent' ) === false ) {
 
 
 			this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) );
 			this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) );
 
 
 		}
 		}
 
 
-		const tangents = attributes.tangent.array;
+		const tangents = this.getAttribute( 'tangent' ).array;
 
 
 		const tan1 = [], tan2 = [];
 		const tan1 = [], tan2 = [];
 
 

+ 1 - 1
src/extras/PMREMGenerator.js

@@ -228,7 +228,7 @@ class PMREMGenerator {
 
 
 		} else { // Equirectangular
 		} else { // Equirectangular
 
 
-			this._setSize( texture.image.width / 4 ?? 256 );
+			this._setSize( texture.image.width / 4 );
 
 
 		}
 		}
 
 

+ 5 - 6
src/extras/core/ShapePath.js

@@ -210,7 +210,7 @@ class ShapePath {
 		if ( newShapes.length > 1 ) {
 		if ( newShapes.length > 1 ) {
 
 
 			let ambiguous = false;
 			let ambiguous = false;
-			const toChange = [];
+			let toChange = 0;
 
 
 			for ( let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
 			for ( let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
 
 
@@ -231,7 +231,8 @@ class ShapePath {
 
 
 						if ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) {
 						if ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) {
 
 
-							if ( sIdx !== s2Idx )	toChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } );
+							if ( sIdx !== s2Idx )	toChange ++;
+
 							if ( hole_unassigned ) {
 							if ( hole_unassigned ) {
 
 
 								hole_unassigned = false;
 								hole_unassigned = false;
@@ -256,12 +257,10 @@ class ShapePath {
 				}
 				}
 
 
 			}
 			}
-			// console.log("ambiguous: ", ambiguous);
 
 
-			if ( toChange.length > 0 ) {
+			if ( toChange > 0 && ambiguous === false ) {
 
 
-				// console.log("to change: ", toChange);
-				if ( ! ambiguous )	newShapeHoles = betterShapeHoles;
+				newShapeHoles = betterShapeHoles;
 
 
 			}
 			}
 
 

+ 6 - 6
src/renderers/webgl/WebGLAttributes.js

@@ -16,16 +16,12 @@ function WebGLAttributes( gl, capabilities ) {
 
 
 		attribute.onUploadCallback();
 		attribute.onUploadCallback();
 
 
-		let type = gl.FLOAT;
+		let type;
 
 
 		if ( array instanceof Float32Array ) {
 		if ( array instanceof Float32Array ) {
 
 
 			type = gl.FLOAT;
 			type = gl.FLOAT;
 
 
-		} else if ( array instanceof Float64Array ) {
-
-			console.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' );
-
 		} else if ( array instanceof Uint16Array ) {
 		} else if ( array instanceof Uint16Array ) {
 
 
 			if ( attribute.isFloat16BufferAttribute ) {
 			if ( attribute.isFloat16BufferAttribute ) {
@@ -36,7 +32,7 @@ function WebGLAttributes( gl, capabilities ) {
 
 
 				} else {
 				} else {
 
 
-					console.warn( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
+					throw new Error( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
 
 
 				}
 				}
 
 
@@ -70,6 +66,10 @@ function WebGLAttributes( gl, capabilities ) {
 
 
 			type = gl.UNSIGNED_BYTE;
 			type = gl.UNSIGNED_BYTE;
 
 
+		} else {
+
+			throw new Error( 'THREE.WebGLAttributes: Unsupported buffer data format: ' + array );
+
 		}
 		}
 
 
 		return {
 		return {