init.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. return {
  2. summary = 'A 4x4 matrix.',
  3. description = [[
  4. A `mat4` is a math type that holds 16 values in a 4x4 grid. They are very useful for
  5. representing and manipulating transforms in 3D space. LÖVR functions that accept 3D transforms
  6. can take a single `mat4` instead of 10 numbers or an assortment of `vec3`s and `quat`s, which
  7. is more concise and improves performance slightly. `mat4`s are created using `lovr.math.mat4`
  8. or by using a `Pool`.
  9. Explaining the math behind `mat4`s and transforms is outside the scope of these docs, but there
  10. are some fairly straightforward functions that can be used to move, rotate, and scale the
  11. transform represented by the matrix:
  12. - `mat4:translate`
  13. - `mat4:rotate`
  14. - `mat4:scale`
  15. The "default" matrix is called the identity matrix and `mat4:identity` can be used to reset any
  16. matrix to the default state.
  17. Matrices can be multiplied together using the normal `*` operator, which combines both of their
  18. transformations into a single matrix. This is really useful for condensing a set of simple
  19. transforms into a more complex one, or creating parent-child relationships between objects.
  20. Note that the multiplication returns a new matrix.
  21. Creating huge numbers of matrices every frame can lead to performance problems due to the sheer
  22. amount of memory allocation and garbage collection overhead. If you need lots of matrix objects
  23. you can use `Pool`s to make things much more efficient.
  24. ]],
  25. constructors = {
  26. 'lovr.math.mat4',
  27. 'Pool:mat4'
  28. },
  29. related = {
  30. 'vec3',
  31. 'quat'
  32. }
  33. }