modeling/src/maths/mat4/fromValues.js

  1. const create = require('./create')
  2. /**
  3. * Create a matrix with the given values.
  4. *
  5. * @param {Number} m00 Component in column 0, row 0 position (index 0)
  6. * @param {Number} m01 Component in column 0, row 1 position (index 1)
  7. * @param {Number} m02 Component in column 0, row 2 position (index 2)
  8. * @param {Number} m03 Component in column 0, row 3 position (index 3)
  9. * @param {Number} m10 Component in column 1, row 0 position (index 4)
  10. * @param {Number} m11 Component in column 1, row 1 position (index 5)
  11. * @param {Number} m12 Component in column 1, row 2 position (index 6)
  12. * @param {Number} m13 Component in column 1, row 3 position (index 7)
  13. * @param {Number} m20 Component in column 2, row 0 position (index 8)
  14. * @param {Number} m21 Component in column 2, row 1 position (index 9)
  15. * @param {Number} m22 Component in column 2, row 2 position (index 10)
  16. * @param {Number} m23 Component in column 2, row 3 position (index 11)
  17. * @param {Number} m30 Component in column 3, row 0 position (index 12)
  18. * @param {Number} m31 Component in column 3, row 1 position (index 13)
  19. * @param {Number} m32 Component in column 3, row 2 position (index 14)
  20. * @param {Number} m33 Component in column 3, row 3 position (index 15)
  21. * @returns {mat4} a new matrix
  22. * @alias module:modeling/maths/mat4.fromValues
  23. * @example
  24. * let matrix = fromValues(
  25. * 1, 0, 0, 1,
  26. * 0, 1, 0, 0,
  27. * 0, 0, 1, 0,
  28. * 0, 0, 0, 1
  29. * )
  30. */
  31. const fromValues = (m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) => {
  32. const out = create()
  33. out[0] = m00
  34. out[1] = m01
  35. out[2] = m02
  36. out[3] = m03
  37. out[4] = m10
  38. out[5] = m11
  39. out[6] = m12
  40. out[7] = m13
  41. out[8] = m20
  42. out[9] = m21
  43. out[10] = m22
  44. out[11] = m23
  45. out[12] = m30
  46. out[13] = m31
  47. out[14] = m32
  48. out[15] = m33
  49. return out
  50. }
  51. module.exports = fromValues