I have a Matrix4<f32>
representing a transformation. I would like to convert it to a [f32; 16]
to use with wgpu.
I've not managed to find the right method (if there is one at all).
I have a Matrix4<f32>
representing a transformation. I would like to convert it to a [f32; 16]
to use with wgpu.
I've not managed to find the right method (if there is one at all).
You can use as_slice()
to convert it into a &[f32]
, and then convert that into a [f32; 16]
using try_into()
.
Here's an example:
fn matrix_to_array(m: Matrix4<f32>) -> [f32; 16] {
m.as_slice().try_into().unwrap()
}