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

Merge pull request #7974 from arose/patch-5

faster BufferGeometry.computeBoundingBox()
......@@ -563,13 +563,33 @@ THREE.BufferGeometry.prototype = {
var bb = this.boundingBox;
bb.makeEmpty();
var minX = +Infinity;
var minY = +Infinity;
var minZ = +Infinity;
var maxX = -Infinity;
var maxY = -Infinity;
var maxZ = -Infinity;
for ( var i = 0, il = positions.length; i < il; i += 3 ) {
vector.fromArray( positions, i );
bb.expandByPoint( vector );
var x = positions[ i ];
var y = positions[ i + 1 ];
var z = positions[ i + 2 ];
minX = Math.min( minX, x );
minY = Math.min( minY, y );
minZ = Math.min( minZ, z );
maxX = Math.max( maxX, x );
maxY = Math.max( maxY, y );
maxZ = Math.max( maxZ, z );
}
this.boundingBox.min.set( minX, minY, minZ );
this.boundingBox.max.set( maxX, maxY, maxZ );
}
if ( positions === undefined || positions.length === 0 ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册