Closed sguimmara closed 1 year ago
What other math library has such a function?
I doesn't seem to make sense to be able to just arbitrarily set 3 elements of a matrix. They aren't the scale for an arbitrary matrix. They're only the scale in specific and very rare situations.
I guess most of the time it is implemented in a transform abstraction, rather than a matrix, then compute the matrix from the P, R, S components.
const transform = new Transform();
transform.scale = [1, 2, 3];
transform.position = [4, 5, 6];
const matrix = transform.computeMatrix();
I wanted to avoid the intermediate transform step and manipulate matrices directly, but I guess this would no be convenient.
Sure, I can see the usefulness of a function that takes translation, rotation, and scale.
Unfortunately there's 48 versions of that function. There's 6 orders of operation
t * r * s
t * s * r
s * t * r
s * r * t
r * t * s
r * s * s
Then there's the definition of r which could be one of these 8
xr * yr * zr
yr * xr * zr
xr * zr * yr
yr * zr * xr
zr * xr * yr
zr * yr * yr
axis + rotation
quat
So, do you provide
trs
, tsr
, rts
, rst
, str
, srt
) an the euler one also takes a rotation order xyz
, xzy
etc...?Either way, I'm not sure I'm personally in the mood to write and test all 48 variations ATM ...
PRs welcome
I ended up writing a Transform
class and specify an order of operations in this class. This is for the best actually, as wgpu-matrix
can remain lightweight.
Maybe I'm missing something, but I don't think it exists yet. It would be great to have a set of functions to set a specific component of a matrix.
i.e
mat4.scaling()
creates a new scale matrix,mat4.scale()
multiplies the scale component by the values. Maybe something likemat4.setScale(src, x, y, z, dst?)
?