diff --git a/build/three.js b/build/three.js index b9cbdcf1f0869e43dfdda75453f4c6e98f9bb122..73638d15db879fea1e7489d4427d5e433dc664ac 100644 --- a/build/three.js +++ b/build/three.js @@ -9007,80 +9007,48 @@ THREE.BufferGeometry.prototype = { computeBoundingBox: function () { - if ( this.boundingBox === null ) { - - this.boundingBox = new THREE.Box3(); - - } + var vector = new THREE.Vector3(); - var positions = this.attributes[ 'position' ].array; + return function () { - if ( positions ) { + if ( this.boundingBox === null ) { - var bb = this.boundingBox; + this.boundingBox = new THREE.Box3(); - if ( positions.length >= 3 ) { - bb.min.x = bb.max.x = positions[ 0 ]; - bb.min.y = bb.max.y = positions[ 1 ]; - bb.min.z = bb.max.z = positions[ 2 ]; } - for ( var i = 3, il = positions.length; i < il; i += 3 ) { - - var x = positions[ i ]; - var y = positions[ i + 1 ]; - var z = positions[ i + 2 ]; - - // bounding box - - if ( x < bb.min.x ) { - - bb.min.x = x; - - } else if ( x > bb.max.x ) { - - bb.max.x = x; - - } - - if ( y < bb.min.y ) { - - bb.min.y = y; - - } else if ( y > bb.max.y ) { - - bb.max.y = y; - - } + var positions = this.attributes[ 'position' ].array; - if ( z < bb.min.z ) { + if ( positions ) { - bb.min.z = z; + var bb = this.boundingBox; + bb.makeEmpty(); - } else if ( z > bb.max.z ) { + for ( var i = 0, il = positions.length; i < il; i += 3 ) { - bb.max.z = z; + vector.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] ); + bb.expandByPoint( vector ); } } - } + if ( positions === undefined || positions.length === 0 ) { - if ( positions === undefined || positions.length === 0 ) { + this.boundingBox.min.set( 0, 0, 0 ); + this.boundingBox.max.set( 0, 0, 0 ); - this.boundingBox.min.set( 0, 0, 0 ); - this.boundingBox.max.set( 0, 0, 0 ); + } - } + if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) { - 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.' ); - console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.' ); + } } - }, + }(), computeBoundingSphere: function () { diff --git a/build/three.min.js b/build/three.min.js index 84e393dfc968303f911aeb8fea6fe888c2d436a1..33235a8d0fd2f820d34ded8805842c05d67d14a2 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -193,20 +193,20 @@ THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,addAttribute:fu b.needsUpdate=!0);b=this.attributes.normal;void 0!==b&&((new THREE.Matrix3).getNormalMatrix(a).applyToVector3Array(b.array),b.needsUpdate=!0)},fromGeometry:function(a,b){b=b||{vertexColors:THREE.NoColors};var c=a.vertices,d=a.faces,e=a.faceVertexUvs,f=b.vertexColors,g=0b.max.x&&(b.max.x=e);fb.max.y&& -(b.max.y=f);gb.max.z&&(b.max.z=g)}}if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0);(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(){var a=new THREE.Box3,b=new THREE.Vector3;return function(){null===this.boundingSphere&& -(this.boundingSphere=new THREE.Sphere);var c=this.attributes.position.array;if(c){a.makeEmpty();for(var d=this.boundingSphere.center,e=0,f=c.length;eI?-1:1;h[4*a]=Ja.x;h[4*a+1]=Ja.y;h[4*a+2]=Ja.z;h[4*a+3]=ab}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var c=this.attributes.index.array,d=this.attributes.position.array,e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&(this.attributes.tangent= -{itemSize:4,array:new Float32Array(4*g)});for(var h=this.attributes.tangent.array,k=[],m=[],n=0;ns;s++)t=a[3*c+s],-1==r[t]?(p[2*s]=t,p[2*s+1]=-1,n++):r[t]k.index+b)for(k={start:f,count:0,index:g},h.push(k),n=0;6>n;n+=2)s=p[n+1],-1n;n+=2)t=p[n],s=p[n+1],-1===s&&(s=g++),r[t]=s,q[s]=t,e[f++]=s-k.index,k.count++}this.reorderBuffers(e,q,g);return this.offsets=h},merge:function(){console.log("BufferGeometry.merge(): TODO")},normalizeNormals:function(){for(var a=this.attributes.normal.array, -b,c,d,e=0,f=a.length;eI?-1:1;h[4*a]=Ja.x;h[4*a+1]=Ja.y;h[4*a+2]=Ja.z;h[4*a+3]=ab}if(void 0===this.attributes.index|| +void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var c=this.attributes.index.array,d=this.attributes.position.array,e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&(this.attributes.tangent={itemSize:4,array:new Float32Array(4*g)});for(var h=this.attributes.tangent.array,k=[],m=[], +n=0;ns;s++)t=a[3*c+s],-1==r[t]?(p[2*s]=t,p[2*s+1]=-1,n++): +r[t]k.index+b)for(k={start:f,count:0,index:g},h.push(k),n=0;6>n;n+=2)s=p[n+1],-1n;n+=2)t=p[n],s=p[n+1],-1===s&&(s=g++),r[t]=s,q[s]=t,e[f++]=s-k.index,k.count++}this.reorderBuffers(e,q,g);return this.offsets=h},merge:function(){console.log("BufferGeometry.merge(): TODO")},normalizeNormals:function(){for(var a=this.attributes.normal.array,b,c,d,e=0,f=a.length;e