Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions examples/jsm/math/Matrix2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export class Matrix2 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this class to the core instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave that up to someone else to decide. With tree shaking I suppose it's not a big deal to move but I'm not sure of what the exact rules are for what belongs in examples vs core.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a case by case decision but since Vector2 is part of the core it seems more consistent to add Matrix2 as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay - I can move it if you'd like!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WestLangley Are you okay with that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - I've just moved the files to core


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;

}

}