提交 6e0c0aae 编写于 作者: M Mr.doob

Simplified Geometry's boundingSphere and boundingBox checks.

上级 11f6d92f
......@@ -69,7 +69,7 @@ THREE.BufferGeometry.prototype = {
computeBoundingBox: function () {
if ( ! this.boundingBox ) {
if ( this.boundingBox === null ) {
this.boundingBox = new THREE.Box3();
......@@ -141,8 +141,10 @@ THREE.BufferGeometry.prototype = {
computeBoundingSphere: function () {
if ( ! this.boundingSphere ) {
if ( this.boundingSphere === null ) {
this.boundingSphere = new THREE.Sphere();
}
var positions = this.attributes[ "position" ].array;
......@@ -251,15 +253,15 @@ THREE.BufferGeometry.prototype = {
ab.sub( pA, pB );
cb.crossSelf( ab );
normals[ vA * 3 ] += cb.x;
normals[ vA * 3 ] += cb.x;
normals[ vA * 3 + 1 ] += cb.y;
normals[ vA * 3 + 2 ] += cb.z;
normals[ vB * 3 ] += cb.x;
normals[ vB * 3 ] += cb.x;
normals[ vB * 3 + 1 ] += cb.y;
normals[ vB * 3 + 2 ] += cb.z;
normals[ vC * 3 ] += cb.x;
normals[ vC * 3 ] += cb.x;
normals[ vC * 3 + 1 ] += cb.y;
normals[ vC * 3 + 2 ] += cb.z;
......
......@@ -577,30 +577,26 @@ THREE.Geometry.prototype = {
computeBoundingBox: function () {
if ( ! this.boundingBox ) {
if ( this.boundingBox === null ) {
this.boundingBox = new THREE.Box3().setFromPoints( this.vertices );
} else {
this.boundingBox.setFromPoints( this.vertices );
this.boundingBox = new THREE.Box3();
}
this.boundingBox.setFromPoints( this.vertices );
},
computeBoundingSphere: function () {
if ( ! this.boundingSphere ) {
if ( this.boundingSphere === null ) {
this.boundingSphere = new THREE.Sphere().setFromCenterAndPoints( new THREE.Vector3(), this.vertices );
} else {
this.boundingSphere.setFromCenterAndPoints( this.boundingSphere.center, this.vertices );
this.boundingSphere = new THREE.Sphere();
}
this.boundingSphere.setFromCenterAndPoints( this.boundingSphere.center, this.vertices );
},
/*
......
......@@ -4,17 +4,8 @@
THREE.Sphere = function ( center, radius ) {
if ( center === undefined && radius === undefined ) {
this.center = new THREE.Vector3();
this.radius = 0;
} else {
this.center = center.clone();
this.radius = radius || 0;
}
this.center = center === undefined ? new THREE.Vector3() : center.clone();
this.radius = radius === undefined ? 0 : radius;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册