Skip to content

Commit 5ad39fd

Browse files
authored
Matrix4: generalize .makeShear() method (mrdoob#21822)
* Generalize .makeShear() method * Clean up * Update Matrix4 unit test
1 parent 05a161c commit 5ad39fd

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

docs/api/en/math/Matrix4.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,21 @@ <h3>[method:this makeScale]( [param:Float x], [param:Float y], [param:Float z] )
317317
</code>
318318
</p>
319319

320-
<h3>[method:this makeShear]( [param:Float x], [param:Float y], [param:Float z] )</h3>
320+
<h3>[method:this makeShear]( [param:Float xy], [param:Float xz], [param:Float yx], [param:Float yz], [param:Float zx], [param:Float zy] )</h3>
321321
<p>
322-
[page:Float x] - the amount to shear in the X axis.<br />
323-
[page:Float y] - the amount to shear in the Y axis.<br />
324-
[page:Float z] - the amount to shear in the Z axis.<br /><br />
322+
[page:Float x] - the amount to shear X by Y.<br />
323+
[page:Float x] - the amount to shear X by Z.<br />
324+
[page:Float x] - the amount to shear Y by X.<br />
325+
[page:Float x] - the amount to shear Y by Z.<br />
326+
[page:Float y] - the amount to shear Z by X.<br />
327+
[page:Float z] - the amount to shear Z by Y.<br /><br />
325328

326329
Sets this matrix as a shear transform:
327330
<code>
328-
1, y, z, 0,
329-
x, 1, z, 0,
330-
x, y, 1, 0,
331-
0, 0, 0, 1
331+
1, yx, zx, 0,
332+
xy, 1, zy, 0,
333+
xz, yz, 1, 0,
334+
0, 0, 0, 1
332335
</code>
333336
</p>
334337

src/math/Matrix4.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,13 @@ class Matrix4 {
673673

674674
}
675675

676-
makeShear( x, y, z ) {
676+
makeShear( xy, xz, yx, yz, zx, zy ) {
677677

678678
this.set(
679679

680-
1, y, z, 0,
681-
x, 1, z, 0,
682-
x, y, 1, 0,
680+
1, yx, zx, 0,
681+
xy, 1, zy, 0,
682+
xz, yz, 1, 0,
683683
0, 0, 0, 1
684684

685685
);

test/unit/src/math/Matrix4.tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,9 @@ export default QUnit.module( 'Maths', () => {
621621
QUnit.test( "makeShear", ( assert ) => {
622622

623623
var a = new Matrix4();
624-
var c = new Matrix4().set( 1, 3, 4, 0, 2, 1, 4, 0, 2, 3, 1, 0, 0, 0, 0, 1 );
624+
var c = new Matrix4().set( 1, 3, 5, 0, 1, 1, 6, 0, 2, 4, 1, 0, 0, 0, 0, 1 );
625625

626-
a.makeShear( 2, 3, 4 );
626+
a.makeShear( 1, 2, 3, 4, 5, 6 );
627627
assert.ok( matrixEquals4( a, c ), "Passed!" );
628628

629629
} );

0 commit comments

Comments
 (0)