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
Color4
to aColor3
, but there is two ways to convertColor3
toColor4
:
Color4.FromColor3
Color3.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 fromColor4
toColor3
.
- Vectors:
- We use
Vector2
andVector3
a lot and there is no way to convert them. I’d love to have eitherVector3.FromVector2
orVector2.toVector3
and 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.FromScalar
that initializes all elements with the same number? Vector3
hastransformCoordinates
whileVector2
hastransform
- 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.TranslationFromVector3
that accepts aVector3
, same forVector2
? - Recently I found
Matrix.Compose
andMatrix.ComposeToRef
. What do you think about aMatrix.ComposeToArray
that directly writes to aFloat32Array
? - In order to copy the contents of a vector to a
Float32Array
, there isVector4.toArray
.Matrix
hascopyToArray
, but there is a second overload toMatrix.toArray
that 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