Selaa lähdekoodia

Matrix4: generalize .makeShear() method (#21822)

* Generalize .makeShear() method

* Clean up

* Update Matrix4 unit test
WestLangley 4 vuotta sitten
vanhempi
commit
5ad39fda0e
3 muutettua tiedostoa jossa 17 lisäystä ja 14 poistoa
  1. 11 8
      docs/api/en/math/Matrix4.html
  2. 4 4
      src/math/Matrix4.js
  3. 2 2
      test/unit/src/math/Matrix4.tests.js

+ 11 - 8
docs/api/en/math/Matrix4.html

@@ -317,18 +317,21 @@ x, 0, 0, 0,
 			</code>
 		</p>
 
-		<h3>[method:this makeShear]( [param:Float x], [param:Float y], [param:Float z] )</h3>
+		<h3>[method:this makeShear]( [param:Float xy], [param:Float xz], [param:Float yx], [param:Float yz], [param:Float zx], [param:Float zy] )</h3>
 		<p>
-		[page:Float x] - the amount to shear in the X axis.<br />
-		[page:Float y] - the amount to shear in the Y axis.<br />
-		[page:Float z] - the amount to shear in the Z axis.<br /><br />
+			[page:Float x] - the amount to shear X by Y.<br />
+			[page:Float x] - the amount to shear X by Z.<br />
+			[page:Float x] - the amount to shear Y by X.<br />
+			[page:Float x] - the amount to shear Y by Z.<br />
+			[page:Float y] - the amount to shear Z by X.<br />
+			[page:Float z] - the amount to shear Z by Y.<br /><br />
 
 		Sets this matrix as a shear transform:
 <code>
-1, y, z, 0,
-x, 1, z, 0,
-x, y, 1, 0,
-0, 0, 0, 1
+1,   yx,  zx,  0,
+xy,   1,  zy,  0,
+xz,  yz,   1,  0,
+0,    0,   0,  1
 </code>
 		</p>
 

+ 4 - 4
src/math/Matrix4.js

@@ -673,13 +673,13 @@ class Matrix4 {
 
 	}
 
-	makeShear( x, y, z ) {
+	makeShear( xy, xz, yx, yz, zx, zy ) {
 
 		this.set(
 
-			1, y, z, 0,
-			x, 1, z, 0,
-			x, y, 1, 0,
+			1, yx, zx, 0,
+			xy, 1, zy, 0,
+			xz, yz, 1, 0,
 			0, 0, 0, 1
 
 		);

+ 2 - 2
test/unit/src/math/Matrix4.tests.js

@@ -621,9 +621,9 @@ export default QUnit.module( 'Maths', () => {
 		QUnit.test( "makeShear", ( assert ) => {
 
 			var a = new Matrix4();
-			var c = new Matrix4().set( 1, 3, 4, 0, 2, 1, 4, 0, 2, 3, 1, 0, 0, 0, 0, 1 );
+			var c = new Matrix4().set( 1, 3, 5, 0, 1, 1, 6, 0, 2, 4, 1, 0, 0, 0, 0, 1 );
 
-			a.makeShear( 2, 3, 4 );
+			a.makeShear( 1, 2, 3, 4, 5, 6 );
 			assert.ok( matrixEquals4( a, c ), "Passed!" );
 
 		} );