Skip to content
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

Merged
merged 5 commits into from
Jul 21, 2024
Merged

Core: Add Matrix2 class #28923

merged 5 commits into from
Jul 21, 2024

Conversation

gkjohnson
Copy link
Collaborator

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

@gkjohnson gkjohnson added this to the r167 milestone Jul 20, 2024
@@ -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

@gkjohnson gkjohnson changed the title Examples: Add Matrix2 class Core: Add Matrix2 class Jul 20, 2024
Copy link

github-actions bot commented Jul 20, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
683.7 kB (169.3 kB) 684 kB (169.4 kB) +314 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
460.9 kB (111.2 kB) 460.9 kB (111.2 kB) +0 B

@@ -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';
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also docs. 🙏

@gkjohnson gkjohnson merged commit b59ac41 into mrdoob:dev Jul 21, 2024
12 checks passed
@gkjohnson gkjohnson deleted the add-mat2 branch July 21, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants