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

Merge remote-tracking branch 'WestLangley/dev-bb' into dev

......@@ -41,8 +41,6 @@ THREE.Object3D = function () {
this.frustumCulled = true;
this.boundingBox = null;
this.userData = {};
};
......@@ -444,53 +442,6 @@ THREE.Object3D.prototype = {
},
computeBoundingBox: function() {
// computes the world-axis-aligned bounding box of object (including its children),
// accounting for both the object's and childrens' world transforms
var v1 = new THREE.Vector3();
return function() {
if ( this.boundingBox === null ) {
this.boundingBox = new THREE.Box3();
}
this.boundingBox.makeEmpty();
var scope = this.boundingBox;
this.updateMatrixWorld( true );
this.traverse( function ( node ) {
if ( node.geometry !== undefined && node.geometry.vertices !== undefined ) {
var vertices = node.geometry.vertices;
for ( var i = 0, il = vertices.length; i < il; i++ ) {
v1.copy( vertices[ i ] );
v1.applyMatrix4( node.matrixWorld );
scope.expandByPoint( v1 );
}
}
} );
return this.boundingBox;
};
}(),
clone: function ( object, recursive ) {
if ( object === undefined ) object = new THREE.Object3D();
......@@ -525,12 +476,6 @@ THREE.Object3D.prototype = {
object.frustumCulled = this.frustumCulled;
if ( this.boundingBox instanceof THREE.Box3 ) {
object.boundingBox = this.boundingBox.clone();
}
object.userData = JSON.parse( JSON.stringify( this.userData ) );
if ( recursive === true ) {
......
......@@ -20,10 +20,10 @@ THREE.BoundingBoxHelper.prototype = Object.create( THREE.Mesh.prototype );
THREE.BoundingBoxHelper.prototype.update = function () {
this.object.computeBoundingBox();
this.box.setFromObject( this.object );
this.object.boundingBox.size( this.scale );
this.box.size( this.scale );
this.object.boundingBox.center( this.position );
this.box.center( this.position );
};
/**
* @author bhouston / http://exocortex.com
* @author WestLangley / http://github.com/WestLangley
*/
THREE.Box3 = function ( min, max ) {
......@@ -94,6 +95,47 @@ THREE.Box3.prototype = {
}(),
setFromObject: function() {
// Computes the world-axis-aligned bounding box of an object (including its children),
// accounting for both the object's, and childrens', world transforms
var v1 = new THREE.Vector3();
return function( object ) {
var scope = this;
object.updateMatrixWorld( true );
this.makeEmpty();
object.traverse( function ( node ) {
if ( node.geometry !== undefined && node.geometry.vertices !== undefined ) {
var vertices = node.geometry.vertices;
for ( var i = 0, il = vertices.length; i < il; i++ ) {
v1.copy( vertices[ i ] );
v1.applyMatrix4( node.matrixWorld );
scope.expandByPoint( v1 );
}
}
} );
return this;
};
}(),
copy: function ( box ) {
this.min.copy( box.min );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册