2
0
Эх сурвалжийг харах

Box3: .setFromObject() use Vector3.fromAttribute

Mugen87 8 жил өмнө
parent
commit
2eeb7a8f3e

+ 1 - 3
src/math/Box3.js

@@ -165,9 +165,7 @@ Box3.prototype = {
 
 							for ( i = 0, l = attribute.count; i < l; i ++ ) {
 
-								v1.x = attribute.getX( i );
-								v1.y = attribute.getY( i );
-								v1.z = attribute.getZ( i );
+								v1.fromAttribute( attribute, i );
 								v1.applyMatrix4( node.matrixWorld );
 
 								scope.expandByPoint( v1 );

+ 4 - 8
src/math/Vector2.js

@@ -87,7 +87,7 @@ Vector2.prototype = {
 			default: throw new Error( 'index is out of range: ' + index );
 
 		}
-		
+
 		return this;
 
 	},
@@ -453,14 +453,10 @@ Vector2.prototype = {
 
 	},
 
-	fromAttribute: function ( attribute, index, offset ) {
-
-		if ( offset === undefined ) offset = 0;
-
-		index = index * attribute.itemSize + offset;
+	fromAttribute: function ( attribute, index ) {
 
-		this.x = attribute.array[ index ];
-		this.y = attribute.array[ index + 1 ];
+		this.x = attribute.getX( index );
+		this.y = attribute.getY( index );
 
 		return this;
 

+ 4 - 8
src/math/Vector3.js

@@ -761,15 +761,11 @@ Vector3.prototype = {
 
 	},
 
-	fromAttribute: function ( attribute, index, offset ) {
+	fromAttribute: function ( attribute, index ) {
 
-		if ( offset === undefined ) offset = 0;
-
-		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;
 

+ 6 - 10
src/math/Vector4.js

@@ -86,7 +86,7 @@ Vector4.prototype = {
 			default: throw new Error( 'index is out of range: ' + index );
 
 		}
-		
+
 		return this;
 
 	},
@@ -611,16 +611,12 @@ Vector4.prototype = {
 
 	},
 
-	fromAttribute: function ( attribute, index, offset ) {
-
-		if ( offset === undefined ) offset = 0;
-
-		index = index * attribute.itemSize + offset;
+	fromAttribute: function ( attribute, index ) {
 
-		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;