Skip to content

Commit 968dff5

Browse files
committed
Pick Matrix2 from mrdoob#28923
1 parent a908fa6 commit 968dff5

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/Three.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export { Sphere } from './math/Sphere.js';
122122
export { Ray } from './math/Ray.js';
123123
export { Matrix4 } from './math/Matrix4.js';
124124
export { Matrix3 } from './math/Matrix3.js';
125+
export { Matrix2 } from './math/Matrix2.js';
125126
export { Box3 } from './math/Box3.js';
126127
export { Box2 } from './math/Box2.js';
127128
export { Line3 } from './math/Line3.js';

src/math/Matrix2.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
export class Matrix2 {
2+
3+
constructor( n11, n12, n21, n22 ) {
4+
5+
Matrix2.prototype.isMatrix2 = true;
6+
7+
this.elements = [
8+
1, 0,
9+
0, 1,
10+
];
11+
12+
if ( n11 !== undefined ) {
13+
14+
this.set( n11, n12, n21, n22 );
15+
16+
}
17+
18+
}
19+
20+
identity() {
21+
22+
this.set(
23+
1, 0,
24+
0, 1,
25+
);
26+
27+
return this;
28+
29+
}
30+
31+
fromArray( array, offset = 0 ) {
32+
33+
for ( let i = 0; i < 4; i ++ ) {
34+
35+
this.elements[ i ] = array[ i + offset ];
36+
37+
}
38+
39+
return this;
40+
41+
}
42+
43+
set( n11, n12, n21, n22 ) {
44+
45+
const te = this.elements;
46+
47+
te[ 0 ] = n11; te[ 2 ] = n12;
48+
te[ 1 ] = n21; te[ 3 ] = n22;
49+
50+
return this;
51+
52+
}
53+
54+
}

0 commit comments

Comments
 (0)