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

BufferGeometry: More efficient bounding* code.

@benadams Oh wait, is this because the strides stuff?
上级 484955ef
...@@ -466,16 +466,16 @@ THREE.BufferGeometry.prototype = { ...@@ -466,16 +466,16 @@ THREE.BufferGeometry.prototype = {
} }
var positions = this.attributes.position; var positions = this.attributes.position.array;
if ( positions ) { if ( positions ) {
var bb = this.boundingBox; var bb = this.boundingBox;
bb.makeEmpty(); bb.makeEmpty();
for ( var i = 0, il = positions.length / positions.itemSize; i < il; i ++ ) { for ( var i = 0, il = positions.length; i < il; i ++ ) {
vector.set( positions.getX( i ), positions.getY( i ), positions.getZ( i ) ); vector.fromArray( positions, i );
bb.expandByPoint( vector ); bb.expandByPoint( vector );
} }
...@@ -512,7 +512,7 @@ THREE.BufferGeometry.prototype = { ...@@ -512,7 +512,7 @@ THREE.BufferGeometry.prototype = {
} }
var positions = this.attributes.position; var positions = this.attributes.position.array;
if ( positions ) { if ( positions ) {
...@@ -520,9 +520,9 @@ THREE.BufferGeometry.prototype = { ...@@ -520,9 +520,9 @@ THREE.BufferGeometry.prototype = {
var center = this.boundingSphere.center; var center = this.boundingSphere.center;
for ( var i = 0, il = positions.length / positions.itemSize; i < il; i ++ ) { for ( var i = 0, il = positions.length; i < il; i ++ ) {
vector.set( positions.getX( i ), positions.getY( i ), positions.getZ( i ) ); vector.fromArray( positions, i );
box.expandByPoint( vector ); box.expandByPoint( vector );
} }
...@@ -534,9 +534,9 @@ THREE.BufferGeometry.prototype = { ...@@ -534,9 +534,9 @@ THREE.BufferGeometry.prototype = {
var maxRadiusSq = 0; var maxRadiusSq = 0;
for ( var i = 0, il = positions.length / positions.itemSize; i < il; i ++ ) { for ( var i = 0, il = positions.length; i < il; i ++ ) {
vector.set( positions.getX( i ), positions.getY( i ), positions.getZ( i ) ); vector.fromArray( positions, i );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册