-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Add Matrix2 class #28923
Core: Add Matrix2 class #28923
Conversation
examples/jsm/math/Matrix2.js
Outdated
@@ -0,0 +1,54 @@ | |||
export class Matrix2 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am. Thanks!
There was a problem hiding this comment.
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
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@@ -120,6 +120,7 @@ export { Sphere } from './math/Sphere.js'; | |||
export { Ray } from './math/Ray.js'; | |||
export { Matrix4 } from './math/Matrix4.js'; | |||
export { Matrix3 } from './math/Matrix3.js'; | |||
export { Matrix2 } from './math/Matrix2.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind also adding the entry for Three.WebGPU.js
?
Otherwise the WebGPU build won't have this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also docs. 🙏
Related issue: --
Description
GLSL, Three.js BufferAttributes, and GLTF accessors support 2x2 matrix types so it may be nice to make a basic Matrix2 class available in three so these types can be used and manipulated more easily. This class was originally created for the 3DTilesRendererJS project (see here) for use with the GLTF EXT_structural_metadata extension so data could be read from mat2 buffer accessors and returned in a format similar to Matrix3 and Matrix4.
Only the functions needed for the initial implementation are included here. More can be added by the community over time as needed.
This contribution is funded by Cesium GIS Ecosystem Grant