فهرست منبع

Matrix3/Matrix4: Simplify .applyToBufferAttribute()

Mugen87 8 سال پیش
والد
کامیت
c85879e108
5فایلهای تغییر یافته به همراه18 افزوده شده و 26 حذف شده
  1. 1 3
      docs/api/math/Matrix3.html
  2. 1 3
      docs/api/math/Matrix4.html
  3. 4 4
      src/Three.Legacy.js
  4. 6 8
      src/math/Matrix3.js
  5. 6 8
      src/math/Matrix4.js

+ 1 - 3
docs/api/math/Matrix3.html

@@ -74,9 +74,7 @@ m.elements = [ 11, 21, 31,
 
 		<h3>[method:Array applyToBufferAttribute]( [page:BufferAttribute attribute], [page:Number offset], [page:Number count] )</h3>
 		<div>
-		[page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br />
-		[page:Number offset] - (optional) index in the attribute of the first vector. Default is 0.<br />
-		[page:Number count] - (optional) number of vectors that are processed. Default is attribute.count.<br /><br />
+		[page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br /><br />
 
 		Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute].
 		</div>

+ 1 - 3
docs/api/math/Matrix4.html

@@ -112,9 +112,7 @@ m.elements = [ 11, 21, 31, 41,
 
 		<h3>[method:Array applyToBufferAttribute]( [page:BufferAttribute attribute], [page:Number offset], [page:Number count] )</h3>
 		<div>
-		[page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br />
-		[page:Number offset] - (optional) index in the attribute of the first vector. Default is 0.<br />
-		[page:Number count] - (optional) number of vectors that are processed. Default is attribute.count.<br /><br />
+		[page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br /><br />
 
 		Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute].
 		</div>

+ 4 - 4
src/Three.Legacy.js

@@ -356,8 +356,8 @@ Object.assign( Matrix3.prototype, {
 	},
 	applyToBuffer: function( buffer, offset, length ) {
 
-		console.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute, offset, count ) instead.' );
-		return this.applyToBufferAttribute( buffer, offset, length );
+		console.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );
+		return this.applyToBufferAttribute( buffer );
 
 	}
 
@@ -453,8 +453,8 @@ Object.assign( Matrix4.prototype, {
 	},
 	applyToBuffer: function( buffer, offset, length ) {
 
-		console.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute, offset, count ) instead.' );
-		return this.applyToBufferAttribute( buffer, offset, length );
+		console.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );
+		return this.applyToBufferAttribute( buffer );
 
 	}
 

+ 6 - 8
src/math/Matrix3.js

@@ -123,21 +123,19 @@ Matrix3.prototype = {
 
 		var v1;
 
-		return function applyToBufferAttribute( attribute, offset, count ) {
+		return function applyToBufferAttribute( attribute ) {
 
 			if ( v1 === undefined ) v1 = new Vector3();
-			if ( offset === undefined ) offset = 0;
-			if ( count === undefined ) count = attribute.count;
 
-			for ( var i = 0, j = offset; i < count; i ++, j ++ ) {
+			for ( var i = 0, l = attribute.count; i < l; i ++ ) {
 
-				v1.x = attribute.getX( j );
-				v1.y = attribute.getY( j );
-				v1.z = attribute.getZ( j );
+				v1.x = attribute.getX( i );
+				v1.y = attribute.getY( i );
+				v1.z = attribute.getZ( i );
 
 				v1.applyMatrix3( this );
 
-				attribute.setXYZ( j, v1.x, v1.y, v1.z );
+				attribute.setXYZ( i, v1.x, v1.y, v1.z );
 
 			}
 

+ 6 - 8
src/math/Matrix4.js

@@ -476,21 +476,19 @@ Matrix4.prototype = {
 
 		var v1;
 
-		return function applyToBufferAttribute( attribute, offset, count ) {
+		return function applyToBufferAttribute( attribute ) {
 
 			if ( v1 === undefined ) v1 = new Vector3();
-			if ( offset === undefined ) offset = 0;
-			if ( count === undefined ) count = attribute.count;
 
-			for ( var i = 0, j = offset; i < count; i ++, j ++ ) {
+			for ( var i = 0, l = attribute.count; i < l; i ++ ) {
 
-				v1.x = attribute.getX( j );
-				v1.y = attribute.getY( j );
-				v1.z = attribute.getZ( j );
+				v1.x = attribute.getX( i );
+				v1.y = attribute.getY( i );
+				v1.z = attribute.getZ( i );
 
 				v1.applyMatrix4( this );
 
-				attribute.setXYZ( j, v1.x, v1.y, v1.z );
+				attribute.setXYZ( i, v1.x, v1.y, v1.z );
 
 			}