0

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).

Nils André
  • 571
  • 5
  • 17

1 Answers1

0

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()
}
Bale
  • 553
  • 1
  • 8
  • 19