提交 cb853767 编写于 作者: W WestLangley

Box3: revert setFromObject()

Presumably, the previous version was correct.

FIxes #8432.
上级 53fbc5d5
......@@ -92,35 +92,49 @@ THREE.Box3.prototype = {
// Computes the world-axis-aligned bounding box of an object (including its children),
// accounting for both the object's, and children's, world transforms
var box;
var v1 = new THREE.Vector3();
return function ( object ) {
if ( box === undefined ) box = new THREE.Box3();
var scope = this;
this.makeEmpty();
object.updateMatrixWorld( true );
this.makeEmpty();
object.traverse( function ( node ) {
var geometry = node.geometry;
if ( geometry !== undefined ) {
if ( geometry.boundingBox === null ) {
if ( geometry instanceof THREE.Geometry ) {
geometry.computeBoundingBox();
var vertices = geometry.vertices;
}
for ( var i = 0, il = vertices.length; i < il; i ++ ) {
v1.copy( vertices[ i ] );
v1.applyMatrix4( node.matrixWorld );
scope.expandByPoint( v1 );
}
} else if ( geometry instanceof THREE.BufferGeometry && geometry.attributes[ 'position' ] !== undefined ) {
var positions = geometry.attributes[ 'position' ].array;
for ( var i = 0, il = positions.length; i < il; i += 3 ) {
v1.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );
v1.applyMatrix4( node.matrixWorld );
if ( geometry.boundingBox.isEmpty() === false ) {
scope.expandByPoint( v1 );
box.copy( geometry.boundingBox );
box.applyMatrix4( node.matrixWorld );
scope.union( box );
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册