-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add vector and matrix utility functions #15101
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
* @param offset defines the offset in the target array where to start storing values | ||
*/ | ||
export function ComposeMatrixToArray<T extends Matrix>(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, array: FloatArray, offset: number): void { | ||
const x = rotation._x, |
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.
Isn't it a code duplication of what we already have?
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.
Yes as mentioned in the forum, this is code duplication of Matrix.ComposeToRef
, unfortunately I don't know how to reuse the existing code. Maybe ComposeToRef
could make use of this version, but then you would have the + offset
with an offset of 0.
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/15101/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/15101/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/15101/merge#BCU1XR#0 |
Visualization tests for WebGPU (Experimental) |
WebGL2 visualization test reporter: |
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 not to sure what those new functions bring ?
Is it just a coding style preference ?
Hi Sebavan, As Deltakosh mentioned in the discussion, for the sake of tree-shaking, we should actually not put more functions in Vector and Matrix, but rather add them to the mentioned utility functions file, so I prepared this MR as a base of discussion. Actually, personally I got unsure wether it is worth filling this file utility file already with the missing functions while the majority of this functions remains for now in Vector an Matrix classes respectively. When it is about making the functions pure functions and not part of the classes I can also easily add them somewhere in my project. What do you think? |
I completely agree that new addition should be in this file and this format, but here I am more questioning the general usefulness of those shortcuts and how frequently we would use them to understand if it justifies the extra maintenance and weight in the UMD scenario :-) @deltakosh @RaananW any thoughts? |
Lets keep them in your project for now and reopen if we change our mind then ? |
Utility functions as discussed in:
https://forum.babylonjs.com/t/matrix-vector-color-conversation-and-utilities-cleanup/49818