Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/shapecraft. flo-bit.dev/shapecraft
Something went wrong. Try again.
579 B · 54 lines
JavaScript
at commit da69385e
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455export class Matrix2 {
constructor( n11, n12, n21, n22 ) {
Matrix2.prototype.isMatrix2 = true;
this.elements = [ 1, 0, 0, 1, ];
if ( n11 !== undefined ) {
this.set( n11, n12, n21, n22 );
}
}
identity() {
this.set( 1, 0, 0, 1, );
return this;
}
fromArray( array, offset = 0 ) {
for ( let i = 0; i < 4; i ++ ) {
this.elements[ i ] = array[ i + offset ];
}
return this;
}
set( n11, n12, n21, n22 ) {
const te = this.elements;
te[ 0 ] = n11; te[ 2 ] = n12; te[ 1 ] = n21; te[ 3 ] = n22;
return this;
}
}