@lakuna/umath 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  2. package/dist/algorithms/hypergeometricPmf.js +5 -1
  3. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  4. package/dist/algorithms/primeFactorization.d.ts +1 -1
  5. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  6. package/dist/index.d.ts +0 -3
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +0 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/linalg/DualQuaternion.d.ts +46 -46
  11. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  12. package/dist/linalg/DualQuaternion.js.map +1 -1
  13. package/dist/linalg/Matrix.d.ts +7 -7
  14. package/dist/linalg/Matrix.d.ts.map +1 -1
  15. package/dist/linalg/Matrix2.d.ts +25 -25
  16. package/dist/linalg/Matrix2.d.ts.map +1 -1
  17. package/dist/linalg/Matrix2.js.map +1 -1
  18. package/dist/linalg/Matrix3.d.ts +35 -35
  19. package/dist/linalg/Matrix3.d.ts.map +1 -1
  20. package/dist/linalg/Matrix3.js.map +1 -1
  21. package/dist/linalg/Matrix4.d.ts +64 -59
  22. package/dist/linalg/Matrix4.d.ts.map +1 -1
  23. package/dist/linalg/Matrix4.js +17 -11
  24. package/dist/linalg/Matrix4.js.map +1 -1
  25. package/dist/linalg/Quaternion.d.ts +50 -48
  26. package/dist/linalg/Quaternion.d.ts.map +1 -1
  27. package/dist/linalg/Quaternion.js +11 -12
  28. package/dist/linalg/Quaternion.js.map +1 -1
  29. package/dist/linalg/SlowMatrix.d.ts +8 -8
  30. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  31. package/dist/linalg/SlowMatrix.js.map +1 -1
  32. package/dist/linalg/SlowSquareMatrix.d.ts +1 -1
  33. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  34. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  35. package/dist/linalg/SlowVector.d.ts +15 -15
  36. package/dist/linalg/SlowVector.d.ts.map +1 -1
  37. package/dist/linalg/SlowVector.js.map +1 -1
  38. package/dist/linalg/Vector.d.ts +14 -14
  39. package/dist/linalg/Vector.d.ts.map +1 -1
  40. package/dist/linalg/Vector2.d.ts +51 -51
  41. package/dist/linalg/Vector2.d.ts.map +1 -1
  42. package/dist/linalg/Vector2.js.map +1 -1
  43. package/dist/linalg/Vector3.d.ts +60 -60
  44. package/dist/linalg/Vector3.d.ts.map +1 -1
  45. package/dist/linalg/Vector3.js.map +1 -1
  46. package/dist/linalg/Vector4.d.ts +45 -45
  47. package/dist/linalg/Vector4.d.ts.map +1 -1
  48. package/dist/linalg/Vector4.js.map +1 -1
  49. package/dist/utility/BigNumber.d.ts +5 -5
  50. package/dist/utility/BigNumber.d.ts.map +1 -1
  51. package/dist/utility/BigNumber.js +13 -6
  52. package/dist/utility/BigNumber.js.map +1 -1
  53. package/package.json +36 -36
  54. package/src/algorithms/hypergeometricPmf.ts +2 -0
  55. package/src/algorithms/primeFactorization.ts +1 -1
  56. package/src/index.ts +0 -5
  57. package/src/linalg/DualQuaternion.ts +69 -58
  58. package/src/linalg/Matrix.ts +10 -7
  59. package/src/linalg/Matrix2.ts +43 -32
  60. package/src/linalg/Matrix3.ts +53 -41
  61. package/src/linalg/Matrix4.ts +127 -94
  62. package/src/linalg/Quaternion.ts +90 -75
  63. package/src/linalg/SlowMatrix.ts +12 -9
  64. package/src/linalg/SlowSquareMatrix.ts +1 -1
  65. package/src/linalg/SlowVector.ts +16 -16
  66. package/src/linalg/Vector.ts +14 -14
  67. package/src/linalg/Vector2.ts +104 -76
  68. package/src/linalg/Vector3.ts +125 -92
  69. package/src/linalg/Vector4.ts +93 -62
  70. package/src/utility/BigNumber.ts +22 -11
  71. package/dist/types/AxisAngle.d.ts +0 -12
  72. package/dist/types/AxisAngle.d.ts.map +0 -1
  73. package/dist/types/AxisAngle.js +0 -2
  74. package/dist/types/AxisAngle.js.map +0 -1
  75. package/dist/types/FieldOfView.d.ts +0 -15
  76. package/dist/types/FieldOfView.d.ts.map +0 -1
  77. package/dist/types/FieldOfView.js +0 -2
  78. package/dist/types/FieldOfView.js.map +0 -1
  79. package/dist/utility/createAxisAngleLike.d.ts +0 -10
  80. package/dist/utility/createAxisAngleLike.d.ts.map +0 -1
  81. package/dist/utility/createAxisAngleLike.js +0 -10
  82. package/dist/utility/createAxisAngleLike.js.map +0 -1
  83. package/src/types/AxisAngle.ts +0 -13
  84. package/src/types/FieldOfView.ts +0 -17
  85. package/src/utility/createAxisAngleLike.ts +0 -14
@@ -1,4 +1,3 @@
1
- import type FieldOfView from "../types/FieldOfView.js";
2
1
  import type { DualQuaternionLike } from "./DualQuaternion.js";
3
2
  import type { MatrixLike } from "./Matrix.js";
4
3
  import type SquareMatrix from "./SquareMatrix.js";
@@ -168,7 +167,7 @@ export const fromValues = <T extends Matrix4Like>(
168
167
  * @public
169
168
  */
170
169
  export const fromTranslation = <T extends Matrix4Like>(
171
- vector: Vector3Like,
170
+ vector: Readonly<Vector3Like>,
172
171
  out: T
173
172
  ): T =>
174
173
  fromValues(
@@ -200,7 +199,7 @@ export const fromTranslation = <T extends Matrix4Like>(
200
199
  * @public
201
200
  */
202
201
  export const fromScaling = <T extends Matrix4Like>(
203
- vector: Vector3Like,
202
+ vector: Readonly<Vector3Like>,
204
203
  out: T
205
204
  ): T =>
206
205
  fromValues(
@@ -244,7 +243,7 @@ export const identity = <T extends Matrix4Like>(out: T): T =>
244
243
  */
245
244
  export const fromRotation = <T extends Matrix4Like>(
246
245
  radians: number,
247
- axis: Vector3Like,
246
+ axis: Readonly<Vector3Like>,
248
247
  out: T
249
248
  ): T => {
250
249
  let x = axis[0];
@@ -355,8 +354,8 @@ export const fromZRotation = <T extends Matrix4Like>(
355
354
  * @public
356
355
  */
357
356
  export const fromRotationTranslation = <T extends Matrix4Like>(
358
- rotation: QuaternionLike,
359
- translation: Vector3Like,
357
+ rotation: Readonly<QuaternionLike>,
358
+ translation: Readonly<Vector3Like>,
360
359
  out: T
361
360
  ): T => {
362
361
  const x = rotation[0];
@@ -411,9 +410,9 @@ export const fromRotationTranslation = <T extends Matrix4Like>(
411
410
  * @public
412
411
  */
413
412
  export const fromRotationTranslationScale = <T extends Matrix4Like>(
414
- rotation: QuaternionLike,
415
- translation: Vector3Like,
416
- scaling: Vector3Like,
413
+ rotation: Readonly<QuaternionLike>,
414
+ translation: Readonly<Vector3Like>,
415
+ scaling: Readonly<Vector3Like>,
417
416
  out: T
418
417
  ): T => {
419
418
  const x = rotation[0];
@@ -473,10 +472,10 @@ export const fromRotationTranslationScale = <T extends Matrix4Like>(
473
472
  * @public
474
473
  */
475
474
  export const fromRotationTranslationScaleOrigin = <T extends Matrix4Like>(
476
- rotation: QuaternionLike,
477
- translation: Vector3Like,
478
- scaling: Vector3Like,
479
- origin: Vector3Like,
475
+ rotation: Readonly<QuaternionLike>,
476
+ translation: Readonly<Vector3Like>,
477
+ scaling: Readonly<Vector3Like>,
478
+ origin: Readonly<Vector3Like>,
480
479
  out: T
481
480
  ): T => {
482
481
  const x = rotation[0];
@@ -545,7 +544,7 @@ export const fromRotationTranslationScaleOrigin = <T extends Matrix4Like>(
545
544
  * @public
546
545
  */
547
546
  export const fromQuaternion = <T extends Matrix4Like>(
548
- quaternion: QuaternionLike,
547
+ quaternion: Readonly<QuaternionLike>,
549
548
  out: T
550
549
  ): T => {
551
550
  const x = quaternion[0];
@@ -602,7 +601,7 @@ const iv3 = createVector3Like();
602
601
  * @public
603
602
  */
604
603
  export const fromDualQuaternion = <T extends Matrix4Like>(
605
- quaternion: DualQuaternionLike,
604
+ quaternion: Readonly<DualQuaternionLike>,
606
605
  out: T
607
606
  ): T => {
608
607
  const bx = -quaternion[0];
@@ -785,7 +784,10 @@ export const perspectiveGpu = <T extends Matrix4Like>(
785
784
 
786
785
  /**
787
786
  * Create a perspective projection matrix from a field of view. Useful for generating projection matrices to be used with the WebXR API.
788
- * @param fov - The field of view.
787
+ * @param left - The angle to the left of the field of view in degrees.
788
+ * @param right - The angle to the right of the field of view in degrees.
789
+ * @param bottom - The angle to the bottom of the field of view in degrees.
790
+ * @param top - The angle to the top of the field of view in degrees.
789
791
  * @param near - The near bound of the frustum.
790
792
  * @param far - The far bound of the frustum.
791
793
  * @param out - The matrix to store the result in.
@@ -796,17 +798,20 @@ export const perspectiveGpu = <T extends Matrix4Like>(
796
798
  * @public
797
799
  */
798
800
  export const perspectiveFromFieldOfView = <T extends Matrix4Like>(
799
- fov: FieldOfView,
801
+ left: number,
802
+ right: number,
803
+ bottom: number,
804
+ top: number,
800
805
  near: number,
801
806
  far: number,
802
807
  out: T
803
808
  ): T => {
804
- const upTan = Math.tan(degreesToRadians(fov.upDegrees));
805
- const downTan = Math.tan(degreesToRadians(fov.downDegrees));
806
- const leftTan = Math.tan(degreesToRadians(fov.leftDegrees));
807
- const rightTan = Math.tan(degreesToRadians(fov.rightDegrees));
809
+ const leftTan = Math.tan(degreesToRadians(left));
810
+ const rightTan = Math.tan(degreesToRadians(right));
811
+ const bottomTan = Math.tan(degreesToRadians(bottom));
812
+ const topTan = Math.tan(degreesToRadians(top));
808
813
  const xScale = 2 / (leftTan + rightTan);
809
- const yScale = 2 / (upTan + downTan);
814
+ const yScale = 2 / (topTan + bottomTan);
810
815
  const nf = near - far;
811
816
 
812
817
  return fromValues(
@@ -819,7 +824,7 @@ export const perspectiveFromFieldOfView = <T extends Matrix4Like>(
819
824
  0,
820
825
  0,
821
826
  -(((leftTan - rightTan) * xScale) / 2),
822
- ((upTan - downTan) * yScale) / 2,
827
+ ((topTan - bottomTan) * yScale) / 2,
823
828
  far / nf,
824
829
  -1,
825
830
  0,
@@ -937,9 +942,9 @@ export const orthoGpu = <T extends Matrix4Like>(
937
942
  * @public
938
943
  */
939
944
  export const lookAt = <T extends Matrix4Like>(
940
- eye: Vector3Like,
941
- center: Vector3Like,
942
- up: Vector3Like,
945
+ eye: Readonly<Vector3Like>,
946
+ center: Readonly<Vector3Like>,
947
+ up: Readonly<Vector3Like>,
943
948
  out: T
944
949
  ): T => {
945
950
  const eyex = eye[0];
@@ -1028,9 +1033,9 @@ export const lookAt = <T extends Matrix4Like>(
1028
1033
  * @public
1029
1034
  */
1030
1035
  export const targetTo = <T extends Matrix4Like>(
1031
- eye: Vector3Like,
1032
- target: Vector3Like,
1033
- up: Vector3Like,
1036
+ eye: Readonly<Vector3Like>,
1037
+ target: Readonly<Vector3Like>,
1038
+ up: Readonly<Vector3Like>,
1034
1039
  out: T
1035
1040
  ): T => {
1036
1041
  const eyex = eye[0];
@@ -1094,8 +1099,8 @@ export const targetTo = <T extends Matrix4Like>(
1094
1099
  * @public
1095
1100
  */
1096
1101
  export const add = <T extends Matrix4Like>(
1097
- a: Matrix4Like,
1098
- b: Matrix4Like,
1102
+ a: Readonly<Matrix4Like>,
1103
+ b: Readonly<Matrix4Like>,
1099
1104
  out: T
1100
1105
  ): T =>
1101
1106
  fromValues(
@@ -1125,7 +1130,10 @@ export const add = <T extends Matrix4Like>(
1125
1130
  * @returns Whether or not the matrices are equivalent.
1126
1131
  * @public
1127
1132
  */
1128
- export const equals = (a: Matrix4Like, b: Matrix4Like): boolean =>
1133
+ export const equals = (
1134
+ a: Readonly<Matrix4Like>,
1135
+ b: Readonly<Matrix4Like>
1136
+ ): boolean =>
1129
1137
  approxRelative(a[0], b[0]) &&
1130
1138
  approxRelative(a[1], b[1]) &&
1131
1139
  approxRelative(a[2], b[2]) &&
@@ -1150,7 +1158,10 @@ export const equals = (a: Matrix4Like, b: Matrix4Like): boolean =>
1150
1158
  * @returns Whether the matrices are equivalent.
1151
1159
  * @public
1152
1160
  */
1153
- export const exactEquals = (a: Matrix4Like, b: Matrix4Like): boolean =>
1161
+ export const exactEquals = (
1162
+ a: Readonly<Matrix4Like>,
1163
+ b: Readonly<Matrix4Like>
1164
+ ): boolean =>
1154
1165
  a[0] === b[0] &&
1155
1166
  a[1] === b[1] &&
1156
1167
  a[2] === b[2] &&
@@ -1177,7 +1188,7 @@ export const exactEquals = (a: Matrix4Like, b: Matrix4Like): boolean =>
1177
1188
  * @public
1178
1189
  */
1179
1190
  export const adjoint = <T extends Matrix4Like>(
1180
- matrix: Matrix4Like,
1191
+ matrix: Readonly<Matrix4Like>,
1181
1192
  out: T
1182
1193
  ): T => {
1183
1194
  const a00 = matrix[0];
@@ -1238,7 +1249,10 @@ export const adjoint = <T extends Matrix4Like>(
1238
1249
  * @returns This matrix.
1239
1250
  * @public
1240
1251
  */
1241
- export const copy = <T extends Matrix4Like>(matrix: Matrix4Like, out: T): T =>
1252
+ export const copy = <T extends Matrix4Like>(
1253
+ matrix: Readonly<Matrix4Like>,
1254
+ out: T
1255
+ ): T =>
1242
1256
  fromValues(
1243
1257
  matrix[0],
1244
1258
  matrix[1],
@@ -1266,7 +1280,7 @@ export const copy = <T extends Matrix4Like>(matrix: Matrix4Like, out: T): T =>
1266
1280
  * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
1267
1281
  * @public
1268
1282
  */
1269
- export const frob = (matrix: Matrix4Like): number =>
1283
+ export const frob = (matrix: Readonly<Matrix4Like>): number =>
1270
1284
  Math.hypot(
1271
1285
  matrix[0],
1272
1286
  matrix[1],
@@ -1296,8 +1310,8 @@ export const frob = (matrix: Matrix4Like): number =>
1296
1310
  * @public
1297
1311
  */
1298
1312
  export const multiply = <T extends Matrix4Like>(
1299
- a: Matrix4Like,
1300
- b: Matrix4Like,
1313
+ a: Readonly<Matrix4Like>,
1314
+ b: Readonly<Matrix4Like>,
1301
1315
  out: T
1302
1316
  ): T => {
1303
1317
  const a00 = a[0];
@@ -1365,7 +1379,7 @@ export const multiply = <T extends Matrix4Like>(
1365
1379
  * @public
1366
1380
  */
1367
1381
  export const multiplyScalar = <T extends Matrix4Like>(
1368
- matrix: Matrix4Like,
1382
+ matrix: Readonly<Matrix4Like>,
1369
1383
  scalar: number,
1370
1384
  out: T
1371
1385
  ): T =>
@@ -1401,8 +1415,8 @@ export const multiplyScalar = <T extends Matrix4Like>(
1401
1415
  * @public
1402
1416
  */
1403
1417
  export const multiplyScalarAndAdd = <T extends Matrix4Like>(
1404
- a: Matrix4Like,
1405
- b: Matrix4Like,
1418
+ a: Readonly<Matrix4Like>,
1419
+ b: Readonly<Matrix4Like>,
1406
1420
  scalar: number,
1407
1421
  out: T
1408
1422
  ): T =>
@@ -1436,8 +1450,8 @@ export const multiplyScalarAndAdd = <T extends Matrix4Like>(
1436
1450
  * @public
1437
1451
  */
1438
1452
  export const subtract = <T extends Matrix4Like>(
1439
- a: Matrix4Like,
1440
- b: Matrix4Like,
1453
+ a: Readonly<Matrix4Like>,
1454
+ b: Readonly<Matrix4Like>,
1441
1455
  out: T
1442
1456
  ): T =>
1443
1457
  fromValues(
@@ -1469,7 +1483,7 @@ export const subtract = <T extends Matrix4Like>(
1469
1483
  * @public
1470
1484
  */
1471
1485
  export const transpose = <T extends Matrix4Like>(
1472
- matrix: Matrix4Like,
1486
+ matrix: Readonly<Matrix4Like>,
1473
1487
  out: T
1474
1488
  ): T => {
1475
1489
  if (out === matrix) {
@@ -1522,7 +1536,7 @@ export const transpose = <T extends Matrix4Like>(
1522
1536
  * @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
1523
1537
  * @public
1524
1538
  */
1525
- export const determinant = (matrix: Matrix4Like): number => {
1539
+ export const determinant = (matrix: Readonly<Matrix4Like>): number => {
1526
1540
  const a00 = matrix[0];
1527
1541
  const a01 = matrix[1];
1528
1542
  const a02 = matrix[2];
@@ -1560,7 +1574,7 @@ export const determinant = (matrix: Matrix4Like): number => {
1560
1574
  * @public
1561
1575
  */
1562
1576
  export const invert = <T extends Matrix4Like>(
1563
- matrix: Matrix4Like,
1577
+ matrix: Readonly<Matrix4Like>,
1564
1578
  out: T
1565
1579
  ): T => {
1566
1580
  const a00 = matrix[0];
@@ -1631,8 +1645,8 @@ export const invert = <T extends Matrix4Like>(
1631
1645
  * @public
1632
1646
  */
1633
1647
  export const scale = <T extends Matrix4Like>(
1634
- matrix: Matrix4Like,
1635
- vector: Vector3Like,
1648
+ matrix: Readonly<Matrix4Like>,
1649
+ vector: Readonly<Vector3Like>,
1636
1650
  out: T
1637
1651
  ): T => {
1638
1652
  const x = vector[0];
@@ -1670,8 +1684,8 @@ export const scale = <T extends Matrix4Like>(
1670
1684
  * @public
1671
1685
  */
1672
1686
  export const translate = <T extends Matrix4Like>(
1673
- matrix: Matrix4Like,
1674
- vector: Vector3Like,
1687
+ matrix: Readonly<Matrix4Like>,
1688
+ vector: Readonly<Vector3Like>,
1675
1689
  out: T
1676
1690
  ): T => {
1677
1691
  const x = vector[0];
@@ -1731,9 +1745,9 @@ export const translate = <T extends Matrix4Like>(
1731
1745
  * @public
1732
1746
  */
1733
1747
  export const rotate = <T extends Matrix4Like>(
1734
- matrix: Matrix4Like,
1748
+ matrix: Readonly<Matrix4Like>,
1735
1749
  radians: number,
1736
- axis: Vector3Like,
1750
+ axis: Readonly<Vector3Like>,
1737
1751
  out: T
1738
1752
  ): T => {
1739
1753
  let x = axis[0];
@@ -1818,7 +1832,7 @@ export const rotate = <T extends Matrix4Like>(
1818
1832
  * @public
1819
1833
  */
1820
1834
  export const rotateX = <T extends Matrix4Like>(
1821
- matrix: Matrix4Like,
1835
+ matrix: Readonly<Matrix4Like>,
1822
1836
  r: number,
1823
1837
  out: T
1824
1838
  ): T => {
@@ -1866,7 +1880,7 @@ export const rotateX = <T extends Matrix4Like>(
1866
1880
  * @public
1867
1881
  */
1868
1882
  export const rotateY = <T extends Matrix4Like>(
1869
- matrix: Matrix4Like,
1883
+ matrix: Readonly<Matrix4Like>,
1870
1884
  r: number,
1871
1885
  out: T
1872
1886
  ): T => {
@@ -1914,7 +1928,7 @@ export const rotateY = <T extends Matrix4Like>(
1914
1928
  * @public
1915
1929
  */
1916
1930
  export const rotateZ = <T extends Matrix4Like>(
1917
- matrix: Matrix4Like,
1931
+ matrix: Readonly<Matrix4Like>,
1918
1932
  r: number,
1919
1933
  out: T
1920
1934
  ): T => {
@@ -1961,7 +1975,7 @@ export const rotateZ = <T extends Matrix4Like>(
1961
1975
  * @public
1962
1976
  */
1963
1977
  export const getTranslation = <T extends Vector3Like>(
1964
- matrix: Matrix4Like,
1978
+ matrix: Readonly<Matrix4Like>,
1965
1979
  out: T
1966
1980
  ): T => vector3FromValues(matrix[12], matrix[13], matrix[14], out);
1967
1981
 
@@ -1975,8 +1989,8 @@ export const getTranslation = <T extends Vector3Like>(
1975
1989
  * @public
1976
1990
  */
1977
1991
  export const setTranslation = <T extends Matrix4Like>(
1978
- matrix: Matrix4Like,
1979
- translation: Vector3Like,
1992
+ matrix: Readonly<Matrix4Like>,
1993
+ translation: Readonly<Vector3Like>,
1980
1994
  out: T
1981
1995
  ): T => {
1982
1996
  if (out !== matrix) {
@@ -2010,7 +2024,7 @@ export const setTranslation = <T extends Matrix4Like>(
2010
2024
  * @public
2011
2025
  */
2012
2026
  export const getScaling = <T extends Vector3Like>(
2013
- matrix: Matrix4Like,
2027
+ matrix: Readonly<Matrix4Like>,
2014
2028
  out: T
2015
2029
  ): T =>
2016
2030
  vector3FromValues(
@@ -2029,7 +2043,7 @@ export const getScaling = <T extends Vector3Like>(
2029
2043
  * @public
2030
2044
  */
2031
2045
  export const getRotation = <T extends QuaternionLike>(
2032
- matrix: Matrix4Like,
2046
+ matrix: Readonly<Matrix4Like>,
2033
2047
  out: T
2034
2048
  ): T => {
2035
2049
  getScaling(matrix, iv3);
@@ -2238,7 +2252,9 @@ export default class Matrix4
2238
2252
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
2239
2253
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2240
2254
  */
2241
- public static fromDualQuaternion(quaternion: DualQuaternionLike): Matrix4 {
2255
+ public static fromDualQuaternion(
2256
+ quaternion: Readonly<DualQuaternionLike>
2257
+ ): Matrix4 {
2242
2258
  return fromDualQuaternion(quaternion, new Matrix4());
2243
2259
  }
2244
2260
 
@@ -2249,7 +2265,7 @@ export default class Matrix4
2249
2265
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
2250
2266
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2251
2267
  */
2252
- public static fromQuaternion(quaternion: QuaternionLike): Matrix4 {
2268
+ public static fromQuaternion(quaternion: Readonly<QuaternionLike>): Matrix4 {
2253
2269
  return fromQuaternion(quaternion, new Matrix4());
2254
2270
  }
2255
2271
 
@@ -2260,7 +2276,7 @@ export default class Matrix4
2260
2276
  * @returns The transformation matrix.
2261
2277
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
2262
2278
  */
2263
- public static fromRotation(r: number, axis: Vector3Like): Matrix4 {
2279
+ public static fromRotation(r: number, axis: Readonly<Vector3Like>): Matrix4 {
2264
2280
  return fromRotation(r, axis, new Matrix4());
2265
2281
  }
2266
2282
 
@@ -2273,8 +2289,8 @@ export default class Matrix4
2273
2289
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2274
2290
  */
2275
2291
  public static fromRotationTranslation(
2276
- rotation: QuaternionLike,
2277
- translation: Vector3Like
2292
+ rotation: Readonly<QuaternionLike>,
2293
+ translation: Readonly<Vector3Like>
2278
2294
  ): Matrix4 {
2279
2295
  return fromRotationTranslation(rotation, translation, new Matrix4());
2280
2296
  }
@@ -2289,9 +2305,9 @@ export default class Matrix4
2289
2305
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2290
2306
  */
2291
2307
  public static fromRotationTranslationScale(
2292
- rotation: QuaternionLike,
2293
- translation: Vector3Like,
2294
- scaling: Vector3Like
2308
+ rotation: Readonly<QuaternionLike>,
2309
+ translation: Readonly<Vector3Like>,
2310
+ scaling: Readonly<Vector3Like>
2295
2311
  ): Matrix4 {
2296
2312
  return fromRotationTranslationScale(
2297
2313
  rotation,
@@ -2312,10 +2328,10 @@ export default class Matrix4
2312
2328
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2313
2329
  */
2314
2330
  public static fromRotationTranslationScaleOrigin(
2315
- rotation: QuaternionLike,
2316
- translation: Vector3Like,
2317
- scaling: Vector3Like,
2318
- origin: Vector3Like
2331
+ rotation: Readonly<QuaternionLike>,
2332
+ translation: Readonly<Vector3Like>,
2333
+ scaling: Readonly<Vector3Like>,
2334
+ origin: Readonly<Vector3Like>
2319
2335
  ): Matrix4 {
2320
2336
  return fromRotationTranslationScaleOrigin(
2321
2337
  rotation,
@@ -2332,7 +2348,7 @@ export default class Matrix4
2332
2348
  * @returns The transformation matrix.
2333
2349
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2334
2350
  */
2335
- public static fromScaling(vector: Vector3Like): Matrix4 {
2351
+ public static fromScaling(vector: Readonly<Vector3Like>): Matrix4 {
2336
2352
  return fromScaling(vector, new Matrix4());
2337
2353
  }
2338
2354
 
@@ -2342,7 +2358,7 @@ export default class Matrix4
2342
2358
  * @returns The transformation matrix.
2343
2359
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2344
2360
  */
2345
- public static fromTranslation(vector: Vector3Like): Matrix4 {
2361
+ public static fromTranslation(vector: Readonly<Vector3Like>): Matrix4 {
2346
2362
  return fromTranslation(vector, new Matrix4());
2347
2363
  }
2348
2364
 
@@ -2470,9 +2486,9 @@ export default class Matrix4
2470
2486
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2471
2487
  */
2472
2488
  public static lookAt(
2473
- eye: Vector3Like,
2474
- center: Vector3Like,
2475
- up: Vector3Like = [0, 1, 0]
2489
+ eye: Readonly<Vector3Like>,
2490
+ center: Readonly<Vector3Like>,
2491
+ up: Readonly<Vector3Like> = [0, 1, 0]
2476
2492
  ): Matrix4 {
2477
2493
  return lookAt(eye, center, up, new Matrix4());
2478
2494
  }
@@ -2544,7 +2560,10 @@ export default class Matrix4
2544
2560
 
2545
2561
  /**
2546
2562
  * Create a perspective projection matrix from a field of view. Useful for generating projection matrices to be used with the WebXR API.
2547
- * @param fov - The field of view.
2563
+ * @param left - The angle to the left of the field of view in degrees.
2564
+ * @param right - The angle to the right of the field of view in degrees.
2565
+ * @param bottom - The angle to the bottom of the field of view in degrees.
2566
+ * @param top - The angle to the top of the field of view in degrees.
2548
2567
  * @param near - The near bound of the frustum.
2549
2568
  * @param far - The far bound of the frustum.
2550
2569
  * @returns The perspective projection matrix.
@@ -2553,11 +2572,22 @@ export default class Matrix4
2553
2572
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API | WebXR API}
2554
2573
  */
2555
2574
  public static perspectiveFromFieldOfView(
2556
- fov: FieldOfView,
2575
+ left: number,
2576
+ right: number,
2577
+ bottom: number,
2578
+ top: number,
2557
2579
  near: number,
2558
2580
  far: number
2559
2581
  ): Matrix4 {
2560
- return perspectiveFromFieldOfView(fov, near, far, new Matrix4());
2582
+ return perspectiveFromFieldOfView(
2583
+ left,
2584
+ right,
2585
+ bottom,
2586
+ top,
2587
+ near,
2588
+ far,
2589
+ new Matrix4()
2590
+ );
2561
2591
  }
2562
2592
 
2563
2593
  /**
@@ -2588,9 +2618,9 @@ export default class Matrix4
2588
2618
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2589
2619
  */
2590
2620
  public static targetTo(
2591
- eye: Vector3Like,
2592
- target: Vector3Like,
2593
- up: Vector3Like = [0, 1, 0]
2621
+ eye: Readonly<Vector3Like>,
2622
+ target: Readonly<Vector3Like>,
2623
+ up: Readonly<Vector3Like> = [0, 1, 0]
2594
2624
  ): Matrix4 {
2595
2625
  return targetTo(eye, target, up, new Matrix4());
2596
2626
  }
@@ -2601,7 +2631,7 @@ export default class Matrix4
2601
2631
  * @returns The sum of the matrices.
2602
2632
  * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
2603
2633
  */
2604
- public add(matrix: Matrix4Like): Matrix4 {
2634
+ public add(matrix: Readonly<Matrix4Like>): Matrix4 {
2605
2635
  return add(this, matrix, new Matrix4());
2606
2636
  }
2607
2637
 
@@ -2627,7 +2657,7 @@ export default class Matrix4
2627
2657
  * @param matrix - The matrix to copy.
2628
2658
  * @returns This matrix.
2629
2659
  */
2630
- public copy(matrix: Matrix4Like): this {
2660
+ public copy(matrix: Readonly<Matrix4Like>): this {
2631
2661
  return copy(matrix, this);
2632
2662
  }
2633
2663
 
@@ -2636,7 +2666,7 @@ export default class Matrix4
2636
2666
  * @param matrix - The other matrix.
2637
2667
  * @returns Whether or not the matrices are equivalent.
2638
2668
  */
2639
- public equals(matrix: Matrix4Like): boolean {
2669
+ public equals(matrix: Readonly<Matrix4Like>): boolean {
2640
2670
  return equals(this, matrix);
2641
2671
  }
2642
2672
 
@@ -2645,7 +2675,7 @@ export default class Matrix4
2645
2675
  * @param matrix - The other matrix.
2646
2676
  * @returns Whether or not the matrices are equivalent.
2647
2677
  */
2648
- public exactEquals(matrix: Matrix4Like): boolean {
2678
+ public exactEquals(matrix: Readonly<Matrix4Like>): boolean {
2649
2679
  return exactEquals(this, matrix);
2650
2680
  }
2651
2681
 
@@ -2673,7 +2703,7 @@ export default class Matrix4
2673
2703
  * @returns The product of the matrices.
2674
2704
  * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
2675
2705
  */
2676
- public multiply(matrix: Matrix4Like): Matrix4 {
2706
+ public multiply(matrix: Readonly<Matrix4Like>): Matrix4 {
2677
2707
  return multiply(this, matrix, new Matrix4());
2678
2708
  }
2679
2709
 
@@ -2695,7 +2725,10 @@ export default class Matrix4
2695
2725
  * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
2696
2726
  * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
2697
2727
  */
2698
- public multiplyScalarAndAdd(matrix: Matrix4Like, scalar: number): Matrix4 {
2728
+ public multiplyScalarAndAdd(
2729
+ matrix: Readonly<Matrix4Like>,
2730
+ scalar: number
2731
+ ): Matrix4 {
2699
2732
  return multiplyScalarAndAdd(this, matrix, scalar, new Matrix4());
2700
2733
  }
2701
2734
 
@@ -2706,7 +2739,7 @@ export default class Matrix4
2706
2739
  * @returns The rotated matrix.
2707
2740
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
2708
2741
  */
2709
- public rotate(r: number, axis: Vector3Like): Matrix4 {
2742
+ public rotate(r: number, axis: Readonly<Vector3Like>): Matrix4 {
2710
2743
  return rotate(this, r, axis, new Matrix4());
2711
2744
  }
2712
2745
 
@@ -2746,7 +2779,7 @@ export default class Matrix4
2746
2779
  * @returns The scaled matrix.
2747
2780
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2748
2781
  */
2749
- public scale(vector: Vector3Like): Matrix4 {
2782
+ public scale(vector: Readonly<Vector3Like>): Matrix4 {
2750
2783
  return scale(this, vector, new Matrix4());
2751
2784
  }
2752
2785
 
@@ -2756,7 +2789,7 @@ export default class Matrix4
2756
2789
  * @returns The transformation matrix.
2757
2790
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2758
2791
  */
2759
- public setTranslation(translation: Vector3Like): Matrix4 {
2792
+ public setTranslation(translation: Readonly<Vector3Like>): Matrix4 {
2760
2793
  return setTranslation(this, translation, new Matrix4());
2761
2794
  }
2762
2795
 
@@ -2766,7 +2799,7 @@ export default class Matrix4
2766
2799
  * @returns The difference between the matrices.
2767
2800
  * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
2768
2801
  */
2769
- public subtract(matrix: Matrix4Like): Matrix4 {
2802
+ public subtract(matrix: Readonly<Matrix4Like>): Matrix4 {
2770
2803
  return subtract(this, matrix, new Matrix4());
2771
2804
  }
2772
2805
 
@@ -2776,7 +2809,7 @@ export default class Matrix4
2776
2809
  * @returns The translated matrix.
2777
2810
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
2778
2811
  */
2779
- public translate(vector: Vector3Like): Matrix4 {
2812
+ public translate(vector: Readonly<Vector3Like>): Matrix4 {
2780
2813
  return translate(this, vector, new Matrix4());
2781
2814
  }
2782
2815