浏览代码

BufferGeometry: Check and report NaN cases in computeBoundingBox/computeBoundinSphere.

Mr.doob 11 年之前
父节点
当前提交
422b7118e6
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/core/BufferGeometry.js

+ 12 - 0
src/core/BufferGeometry.js

@@ -149,6 +149,12 @@ THREE.BufferGeometry.prototype = {
 
 		}
 
+		if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
+
+			console.error( 'THREE.BufferGeometry.computeBoundingBox()', 'Computed min/max have NaN values. The "position" attribute is likely to have NaN values.' );
+
+		}
+
 	},
 
 	computeBoundingSphere: function () {
@@ -195,6 +201,12 @@ THREE.BufferGeometry.prototype = {
 
 				this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
 
+				if ( isNaN( this.boundingSphere.radius ) ) {
+
+					console.error( 'THREE.BufferGeometry.computeBoundingSphere()', 'Computed radius is NaN. The "position" attribute is likely to have NaN values.' );
+
+				}
+
 			}
 
 		}