提交 9111feba 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #10303 from Mugen87/dev

Box3: Refactored .setFromObject()
......@@ -138,6 +138,8 @@ Box3.prototype = {
object.traverse( function ( node ) {
var i, l;
var geometry = node.geometry;
if ( geometry !== undefined ) {
......@@ -146,7 +148,7 @@ Box3.prototype = {
var vertices = geometry.vertices;
for ( var i = 0, il = vertices.length; i < il; i ++ ) {
for ( i = 0, l = vertices.length; i < l; i ++ ) {
v1.copy( vertices[ i ] );
v1.applyMatrix4( node.matrixWorld );
......@@ -161,26 +163,9 @@ Box3.prototype = {
if ( attribute !== undefined ) {
var array, offset, stride;
if ( attribute.isInterleavedBufferAttribute ) {
array = attribute.data.array;
offset = attribute.offset;
stride = attribute.data.stride;
} else {
array = attribute.array;
offset = 0;
stride = 3;
}
for ( var i = offset, il = array.length; i < il; i += stride ) {
for ( i = 0, l = attribute.count; i < l; i ++ ) {
v1.fromArray( array, i );
v1.applyMatrix4( node.matrixWorld );
v1.fromAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
scope.expandByPoint( v1 );
......
......@@ -87,7 +87,7 @@ Vector2.prototype = {
default: throw new Error( 'index is out of range: ' + index );
}
return this;
},
......@@ -455,12 +455,14 @@ Vector2.prototype = {
fromAttribute: function ( attribute, index, offset ) {
if ( offset === undefined ) offset = 0;
if ( offset !== undefined ) {
index = index * attribute.itemSize + offset;
console.warn( 'THREE.Vector2: offset has been removed from .fromAttribute().' );
}
this.x = attribute.array[ index ];
this.y = attribute.array[ index + 1 ];
this.x = attribute.getX( index );
this.y = attribute.getY( index );
return this;
......
......@@ -763,13 +763,15 @@ Vector3.prototype = {
fromAttribute: function ( attribute, index, offset ) {
if ( offset === undefined ) offset = 0;
if ( offset !== undefined ) {
console.warn( 'THREE.Vector3: offset has been removed from .fromAttribute().' );
index = index * attribute.itemSize + offset;
}
this.x = attribute.array[ index ];
this.y = attribute.array[ index + 1 ];
this.z = attribute.array[ index + 2 ];
this.x = attribute.getX( index );
this.y = attribute.getY( index );
this.z = attribute.getZ( index );
return this;
......
......@@ -86,7 +86,7 @@ Vector4.prototype = {
default: throw new Error( 'index is out of range: ' + index );
}
return this;
},
......@@ -613,14 +613,16 @@ Vector4.prototype = {
fromAttribute: function ( attribute, index, offset ) {
if ( offset === undefined ) offset = 0;
if ( offset !== undefined ) {
index = index * attribute.itemSize + offset;
console.warn( 'THREE.Vector4: offset has been removed from .fromAttribute().' );
}
this.x = attribute.array[ index ];
this.y = attribute.array[ index + 1 ];
this.z = attribute.array[ index + 2 ];
this.w = attribute.array[ index + 3 ];
this.x = attribute.getX( index );
this.y = attribute.getY( index );
this.z = attribute.getZ( index );
this.w = attribute.getW( index );
return this;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册