Hello,
I am working on a technical application and there I often have to map some data from my data model to vectors, matrices and colors. I noticed that I often have to repeat pieces of code to map my data although there is already plenty of helper functions in the appropriate classes.
Sometimes I noticed there is even 2 helper function that do the exact same thing and I was wondering wether one of them is preferred and the other one should be marked as deprecated.
So here is my list of questions and suggestions. I am willing to contribute here if there is a consent how to move on.
- Colors: There is no way to convert a
Color4to aColor3, but there is two ways to convertColor3toColor4:
Color4.FromColor3Color3.toColor4
Is there a preferred version? I know the first one as “NamedConstructor”. I think it is more verbose while the second one is shorter as you do not have to explicitly mention theColor3. I think I prefer the second one. Is there a reason to have two? I’d probably deprecate one of them and add a way to convert fromColor4toColor3.
- Vectors:
- We use
Vector2andVector3a lot and there is no way to convert them. I’d love to have eitherVector3.FromVector2orVector2.toVector3and vice versa. - Sometimes I need to create a Vector where all elements are initialized to the same scalar, for example to pass it to the scaling vector of
Matrix.Compose. What do you think about aVector.FromScalarthat initializes all elements with the same number? Vector3hastransformCoordinateswhileVector2hastransform
- Matrix:
- I often need to create a Matrix that contains a translation that I already have as a Vector3. Currently, I need to pass
myVector.x,myVector.y,myVector.z. What do you think about aMatrix.TranslationFromVector3that accepts aVector3, same forVector2? - Recently I found
Matrix.ComposeandMatrix.ComposeToRef. What do you think about aMatrix.ComposeToArraythat directly writes to aFloat32Array? - In order to copy the contents of a vector to a
Float32Array, there isVector4.toArray.MatrixhascopyToArray, but there is a second overload toMatrix.toArraythat looks like it behaves the same asVector.toArray. Is one or the other preferred? Should one be deprecated? - I often create a uniform scaling matrix but I need to pass my scaling factor 3 times to
Matrix.Scaling. What do you think about aMatrix.UniformScaling(number)? - There is no
Matrix.multiplyInPlace.
There are the ones that I found and sometimes miss. Are you aware of more things like this? What do you think about my thoughts?
Best regards,
Axel