@lakuna/umath 1.5.0 → 2.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 (73) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +6 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/linalg/DualQuaternion.d.ts +23 -46
  6. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  7. package/dist/linalg/DualQuaternion.js +47 -70
  8. package/dist/linalg/DualQuaternion.js.map +1 -1
  9. package/dist/linalg/Matrix2.d.ts +14 -28
  10. package/dist/linalg/Matrix2.d.ts.map +1 -1
  11. package/dist/linalg/Matrix2.js +28 -42
  12. package/dist/linalg/Matrix2.js.map +1 -1
  13. package/dist/linalg/Matrix3.d.ts +21 -42
  14. package/dist/linalg/Matrix3.d.ts.map +1 -1
  15. package/dist/linalg/Matrix3.js +43 -84
  16. package/dist/linalg/Matrix3.js.map +1 -1
  17. package/dist/linalg/Matrix4.d.ts +39 -78
  18. package/dist/linalg/Matrix4.d.ts.map +1 -1
  19. package/dist/linalg/Matrix4.js +85 -170
  20. package/dist/linalg/Matrix4.js.map +1 -1
  21. package/dist/linalg/Quaternion.d.ts +27 -58
  22. package/dist/linalg/Quaternion.d.ts.map +1 -1
  23. package/dist/linalg/Quaternion.js +54 -85
  24. package/dist/linalg/Quaternion.js.map +1 -1
  25. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  26. package/dist/linalg/SlowMatrix.js +52 -78
  27. package/dist/linalg/SlowMatrix.js.map +1 -1
  28. package/dist/linalg/SlowVector.d.ts +165 -0
  29. package/dist/linalg/SlowVector.d.ts.map +1 -0
  30. package/dist/linalg/SlowVector.js +369 -0
  31. package/dist/linalg/SlowVector.js.map +1 -0
  32. package/dist/linalg/Vector.d.ts +14 -15
  33. package/dist/linalg/Vector.d.ts.map +1 -1
  34. package/dist/linalg/Vector2.d.ts +28 -50
  35. package/dist/linalg/Vector2.d.ts.map +1 -1
  36. package/dist/linalg/Vector2.js +59 -85
  37. package/dist/linalg/Vector2.js.map +1 -1
  38. package/dist/linalg/Vector3.d.ts +32 -58
  39. package/dist/linalg/Vector3.d.ts.map +1 -1
  40. package/dist/linalg/Vector3.js +67 -107
  41. package/dist/linalg/Vector3.js.map +1 -1
  42. package/dist/linalg/Vector4.d.ts +26 -46
  43. package/dist/linalg/Vector4.d.ts.map +1 -1
  44. package/dist/linalg/Vector4.js +54 -82
  45. package/dist/linalg/Vector4.js.map +1 -1
  46. package/dist/utility/MatrixSizeError.d.ts +1 -1
  47. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  48. package/dist/utility/MatrixSizeError.js +1 -1
  49. package/dist/utility/MatrixSizeError.js.map +1 -1
  50. package/dist/utility/VectorSizeError.d.ts +12 -0
  51. package/dist/utility/VectorSizeError.d.ts.map +1 -0
  52. package/dist/utility/VectorSizeError.js +15 -0
  53. package/dist/utility/VectorSizeError.js.map +1 -0
  54. package/dist/utility/createAxisAngleLike.d.ts +10 -0
  55. package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
  56. package/dist/utility/createAxisAngleLike.js +10 -0
  57. package/dist/utility/createAxisAngleLike.js.map +1 -0
  58. package/package.json +1 -3
  59. package/src/index.ts +7 -0
  60. package/src/linalg/DualQuaternion.ts +51 -134
  61. package/src/linalg/Matrix2.ts +30 -81
  62. package/src/linalg/Matrix3.ts +55 -149
  63. package/src/linalg/Matrix4.ts +135 -291
  64. package/src/linalg/Quaternion.ts +60 -151
  65. package/src/linalg/SlowMatrix.ts +82 -81
  66. package/src/linalg/SlowVector.ts +449 -0
  67. package/src/linalg/Vector.ts +14 -16
  68. package/src/linalg/Vector2.ts +63 -153
  69. package/src/linalg/Vector3.ts +75 -194
  70. package/src/linalg/Vector4.ts +60 -143
  71. package/src/utility/MatrixSizeError.ts +1 -1
  72. package/src/utility/VectorSizeError.ts +14 -0
  73. package/src/utility/createAxisAngleLike.ts +13 -0
@@ -94,7 +94,7 @@ export const fromRotation = (radians, axis, out) => {
94
94
  let x = axis[0];
95
95
  let y = axis[1];
96
96
  let z = axis[2];
97
- let len = Math.sqrt(x * x + y * y + z * z);
97
+ let len = Math.hypot(x, y, z);
98
98
  if (len === 0) {
99
99
  throw new MagnitudeError();
100
100
  }
@@ -516,14 +516,14 @@ export const lookAt = (eye, center, up, out) => {
516
516
  let z0 = eyex - centerx;
517
517
  let z1 = eyey - centery;
518
518
  let z2 = eyez - centerz;
519
- let len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); // `Math.hypot` is slower.
519
+ let len = 1 / Math.hypot(z0, z1, z2);
520
520
  z0 *= len;
521
521
  z1 *= len;
522
522
  z2 *= len;
523
523
  let x0 = upy * z2 - upz * z1;
524
524
  let x1 = upz * z0 - upx * z2;
525
525
  let x2 = upx * z1 - upy * z0;
526
- len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
526
+ len = Math.hypot(x0, x1, x2);
527
527
  if (len) {
528
528
  len = 1 / len;
529
529
  x0 *= len;
@@ -538,7 +538,7 @@ export const lookAt = (eye, center, up, out) => {
538
538
  let y0 = z1 * x2 - z2 * x1;
539
539
  let y1 = z2 * x0 - z0 * x2;
540
540
  let y2 = z0 * x1 - z1 * x0;
541
- len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
541
+ len = Math.hypot(y0, y1, y2);
542
542
  if (len) {
543
543
  len = 1 / len;
544
544
  y0 *= len;
@@ -701,41 +701,7 @@ export const copy = (matrix, out) => fromValues(matrix[0], matrix[1], matrix[2],
701
701
  * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
702
702
  * @public
703
703
  */
704
- export const frob = (matrix) => {
705
- const a00 = matrix[0];
706
- const a01 = matrix[1];
707
- const a02 = matrix[2];
708
- const a03 = matrix[3];
709
- const a10 = matrix[4];
710
- const a11 = matrix[5];
711
- const a12 = matrix[6];
712
- const a13 = matrix[7];
713
- const a20 = matrix[8];
714
- const a21 = matrix[9];
715
- const a22 = matrix[10];
716
- const a23 = matrix[11];
717
- const a30 = matrix[12];
718
- const a31 = matrix[13];
719
- const a32 = matrix[14];
720
- const a33 = matrix[15];
721
- // `Math.hypot` is slower.
722
- return Math.sqrt(a00 * a00 +
723
- a01 * a01 +
724
- a02 * a02 +
725
- a03 * a03 +
726
- a10 * a10 +
727
- a11 * a11 +
728
- a12 * a12 +
729
- a13 * a13 +
730
- a20 * a20 +
731
- a21 * a21 +
732
- a22 * a22 +
733
- a23 * a23 +
734
- a30 * a30 +
735
- a31 * a31 +
736
- a32 * a32 +
737
- a33 * a33);
738
- };
704
+ export const frob = (matrix) => Math.hypot(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]);
739
705
  /**
740
706
  * Multiply two matrices.
741
707
  * @param a - The multiplier.
@@ -982,7 +948,7 @@ export const rotate = (matrix, radians, axis, out) => {
982
948
  let x = axis[0];
983
949
  let y = axis[1];
984
950
  let z = axis[2];
985
- let len = Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
951
+ let len = Math.hypot(x, y, z);
986
952
  if (len < epsilon) {
987
953
  return out;
988
954
  }
@@ -1207,19 +1173,7 @@ export const setTranslation = (matrix, translation, out) => {
1207
1173
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1208
1174
  * @public
1209
1175
  */
1210
- export const getScaling = (matrix, out) => {
1211
- const m11 = matrix[0];
1212
- const m12 = matrix[1];
1213
- const m13 = matrix[2];
1214
- const m21 = matrix[4];
1215
- const m22 = matrix[5];
1216
- const m23 = matrix[6];
1217
- const m31 = matrix[8];
1218
- const m32 = matrix[9];
1219
- const m33 = matrix[10];
1220
- // `Math.hypot` is slower.
1221
- return vector3FromValues(Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13), Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23), Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33), out);
1222
- };
1176
+ export const getScaling = (matrix, out) => vector3FromValues(Math.hypot(matrix[0], matrix[1], matrix[2]), Math.hypot(matrix[4], matrix[5], matrix[6]), Math.hypot(matrix[8], matrix[9], matrix[10]), out);
1223
1177
  /**
1224
1178
  * Get the rotational component of a transformation matrix.
1225
1179
  * @param matrix - The matrix.
@@ -1267,88 +1221,80 @@ export default class Matrix4 extends Float32Array {
1267
1221
  /**
1268
1222
  * Create a transformation matrix that represents a translation by the given vector.
1269
1223
  * @param vector - The translation vector.
1270
- * @param out - The matrix to store the result in.
1271
1224
  * @returns The transformation matrix.
1272
1225
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1273
1226
  */
1274
- static fromTranslation(vector, out = new Matrix4()) {
1275
- return fromTranslation(vector, out);
1227
+ static fromTranslation(vector) {
1228
+ return fromTranslation(vector, new Matrix4());
1276
1229
  }
1277
1230
  /**
1278
1231
  * Create a transformation matrix that represents a scaling by the given vector.
1279
1232
  * @param vector - The scaling vector.
1280
- * @param out - The matrix to store the result in.
1281
1233
  * @returns The transformation matrix.
1282
1234
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1283
1235
  */
1284
- static fromScaling(vector, out = new Matrix4()) {
1285
- return fromScaling(vector, out);
1236
+ static fromScaling(vector) {
1237
+ return fromScaling(vector, new Matrix4());
1286
1238
  }
1287
1239
  /**
1288
1240
  * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
1289
1241
  * @param r - The angle in radians.
1290
1242
  * @param axis - The axis to rotate around.
1291
- * @param out - The matrix to store the result in.
1292
1243
  * @returns The transformation matrix.
1293
1244
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1294
1245
  */
1295
- static fromRotation(r, axis, out = new Matrix4()) {
1296
- return fromRotation(r, axis, out);
1246
+ static fromRotation(r, axis) {
1247
+ return fromRotation(r, axis, new Matrix4());
1297
1248
  }
1298
1249
  /**
1299
1250
  * Create a transformation matrix that represents a rotation by the given angle around the X-axis.
1300
1251
  * @param r - The angle in radians.
1301
- * @param out - The matrix to store the result in.
1302
1252
  * @returns The transformation matrix.
1303
1253
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1304
1254
  */
1305
- static fromXRotation(r, out = new Matrix4()) {
1306
- return fromXRotation(r, out);
1255
+ static fromXRotation(r) {
1256
+ return fromXRotation(r, new Matrix4());
1307
1257
  }
1308
1258
  /**
1309
1259
  * Create a transformation matrix that represents a rotation by the given angle around the Y-axis.
1310
1260
  * @param r - The angle in radians.
1311
- * @param out - The matrix to store the result in.
1312
1261
  * @returns The transformation matrix.
1313
1262
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1314
1263
  */
1315
- static fromYRotation(r, out = new Matrix4()) {
1316
- return fromYRotation(r, out);
1264
+ static fromYRotation(r) {
1265
+ return fromYRotation(r, new Matrix4());
1317
1266
  }
1318
1267
  /**
1319
1268
  * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
1320
1269
  * @param r - The angle in radians.
1321
- * @param out - The matrix to store the result in.
1322
1270
  * @returns The transformation matrix.
1323
1271
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1324
1272
  */
1325
- static fromZRotation(r, out = new Matrix4()) {
1326
- return fromZRotation(r, out);
1273
+ static fromZRotation(r) {
1274
+ return fromZRotation(r, new Matrix4());
1327
1275
  }
1328
1276
  /**
1329
1277
  * Create a transformation matrix from the given rotation and translation.
1330
1278
  * @param rotation - The rotation quaternion.
1331
1279
  * @param translation - The translation vector.
1332
- * @param out - The matrix to store the result in.
1333
1280
  * @returns The transformation matrix.
1334
1281
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1335
1282
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1336
1283
  */
1337
- static fromRotationTranslation(rotation, translation, out = new Matrix4()) {
1338
- return fromRotationTranslation(rotation, translation, out);
1284
+ static fromRotationTranslation(rotation, translation) {
1285
+ return fromRotationTranslation(rotation, translation, new Matrix4());
1339
1286
  }
1340
1287
  /**
1341
1288
  * Create a transformation matrix from the given rotation, translation, and scale.
1342
1289
  * @param rotation - The rotation quaternion.
1343
1290
  * @param translation - The translation vector.
1344
1291
  * @param scaling - The scaling vector.
1345
- * @param out - The matrix to store the result in.
1346
1292
  * @returns The transformation matrix.
1347
1293
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1348
1294
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1349
1295
  */
1350
- static fromRotationTranslationScale(rotation, translation, scaling, out = new Matrix4()) {
1351
- return fromRotationTranslationScale(rotation, translation, scaling, out);
1296
+ static fromRotationTranslationScale(rotation, translation, scaling) {
1297
+ return fromRotationTranslationScale(rotation, translation, scaling, new Matrix4());
1352
1298
  }
1353
1299
  /**
1354
1300
  * Create a transformation matrix from the given rotation, translation, and scale around the given origin.
@@ -1356,36 +1302,33 @@ export default class Matrix4 extends Float32Array {
1356
1302
  * @param translation - The translation vector.
1357
1303
  * @param scaling - The scaling vector.
1358
1304
  * @param origin - The origin vector.
1359
- * @param out - The matrix to store the result in.
1360
1305
  * @returns The transformation matrix.
1361
1306
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1362
1307
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1363
1308
  */
1364
- static fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin, out = new Matrix4()) {
1365
- return fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin, out);
1309
+ static fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin) {
1310
+ return fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin, new Matrix4());
1366
1311
  }
1367
1312
  /**
1368
1313
  * Create a transformation matrix from a dual quaternion.
1369
1314
  * @param quaternion - The dual quaternion.
1370
- * @param out - The matrix to store the result in.
1371
1315
  * @returns The transformation matrix.
1372
1316
  * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
1373
1317
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1374
1318
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1375
1319
  */
1376
- static fromDualQuaternion(quaternion, out = new Matrix4()) {
1377
- return fromDualQuaternion(quaternion, out);
1320
+ static fromDualQuaternion(quaternion) {
1321
+ return fromDualQuaternion(quaternion, new Matrix4());
1378
1322
  }
1379
1323
  /**
1380
1324
  * Create a transformation matrix from a quaternion.
1381
1325
  * @param quaternion - The quaternion.
1382
- * @param out - The matrix to store the result in.
1383
1326
  * @returns The transformation matrix.
1384
1327
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1385
1328
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1386
1329
  */
1387
- static fromQuaternion(quaternion, out = new Matrix4()) {
1388
- return fromQuaternion(quaternion, out);
1330
+ static fromQuaternion(quaternion) {
1331
+ return fromQuaternion(quaternion, new Matrix4());
1389
1332
  }
1390
1333
  /**
1391
1334
  * Generate a frustum matrix with the given bounds.
@@ -1395,13 +1338,12 @@ export default class Matrix4 extends Float32Array {
1395
1338
  * @param top - The top bound of the frustum.
1396
1339
  * @param near - The near bound of the frustum.
1397
1340
  * @param far - The far bound of the frustum.
1398
- * @param out - The matrix to store the result in.
1399
1341
  * @returns The frustum matrix.
1400
1342
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1401
1343
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1402
1344
  */
1403
- static frustum(left, right, bottom, top, near, far, out = new Matrix4()) {
1404
- return frustum(left, right, bottom, top, near, far, out);
1345
+ static frustum(left, right, bottom, top, near, far) {
1346
+ return frustum(left, right, bottom, top, near, far, new Matrix4());
1405
1347
  }
1406
1348
  /**
1407
1349
  * Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[-1, 1]` (OpenGL/WebGL).
@@ -1409,13 +1351,12 @@ export default class Matrix4 extends Float32Array {
1409
1351
  * @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
1410
1352
  * @param near - The near bound of the frustum.
1411
1353
  * @param far - The far bound of the frustum.
1412
- * @param out - The matrix to store the result in.
1413
1354
  * @returns The perspective projection matrix.
1414
1355
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1415
1356
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1416
1357
  */
1417
- static perspective(fov, aspect, near, far, out = new Matrix4()) {
1418
- return perspective(fov, aspect, near, far, out);
1358
+ static perspective(fov, aspect, near, far) {
1359
+ return perspective(fov, aspect, near, far, new Matrix4());
1419
1360
  }
1420
1361
  /**
1421
1362
  * Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[0, 1]` (WebGPU/Vulkan/DirectX/Metal).
@@ -1423,27 +1364,25 @@ export default class Matrix4 extends Float32Array {
1423
1364
  * @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
1424
1365
  * @param near - The near bound of the frustum.
1425
1366
  * @param far - The far bound of the frustum.
1426
- * @param out - The matrix to store the result in.
1427
1367
  * @returns The perspective projection matrix.
1428
1368
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1429
1369
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1430
1370
  */
1431
- static perspectiveGpu(fov, aspect, near, far, out = new Matrix4()) {
1432
- return perspectiveGpu(fov, aspect, near, far, out);
1371
+ static perspectiveGpu(fov, aspect, near, far) {
1372
+ return perspectiveGpu(fov, aspect, near, far, new Matrix4());
1433
1373
  }
1434
1374
  /**
1435
1375
  * Create a perspective projection matrix from a field of view. Useful for generating projection matrices to be used with the WebXR API.
1436
1376
  * @param fov - The field of view.
1437
1377
  * @param near - The near bound of the frustum.
1438
1378
  * @param far - The far bound of the frustum.
1439
- * @param out - The matrix to store the result in.
1440
1379
  * @returns The perspective projection matrix.
1441
1380
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1442
1381
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1443
1382
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API | WebXR API}
1444
1383
  */
1445
- static perspectiveFromFieldOfView(fov, near, far, out = new Matrix4()) {
1446
- return perspectiveFromFieldOfView(fov, near, far, out);
1384
+ static perspectiveFromFieldOfView(fov, near, far) {
1385
+ return perspectiveFromFieldOfView(fov, near, far, new Matrix4());
1447
1386
  }
1448
1387
  /**
1449
1388
  * Generate an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[-1, 1]` (OpenGL/WebGL).
@@ -1453,13 +1392,12 @@ export default class Matrix4 extends Float32Array {
1453
1392
  * @param top - The top bound of the frustum.
1454
1393
  * @param near - The near bound of the frustum.
1455
1394
  * @param far - The far bound of the frustum.
1456
- * @param out - The matrix to store the result in.
1457
1395
  * @returns The frustum matrix.
1458
1396
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1459
1397
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1460
1398
  */
1461
- static ortho(left, right, bottom, top, near, far, out = new Matrix4()) {
1462
- return ortho(left, right, bottom, top, near, far, out);
1399
+ static ortho(left, right, bottom, top, near, far) {
1400
+ return ortho(left, right, bottom, top, near, far, new Matrix4());
1463
1401
  }
1464
1402
  /**
1465
1403
  * Generate an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[0, 1]` (WebGPU/Vulkan/DirectX/Metal).
@@ -1469,37 +1407,34 @@ export default class Matrix4 extends Float32Array {
1469
1407
  * @param top - The top bound of the frustum.
1470
1408
  * @param near - The near bound of the frustum.
1471
1409
  * @param far - The far bound of the frustum.
1472
- * @param out - The matrix to store the result in.
1473
1410
  * @returns The frustum matrix.
1474
1411
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1475
1412
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1476
1413
  */
1477
- static orthoGpu(left, right, bottom, top, near, far, out = new Matrix4()) {
1478
- return orthoGpu(left, right, bottom, top, near, far, out);
1414
+ static orthoGpu(left, right, bottom, top, near, far) {
1415
+ return orthoGpu(left, right, bottom, top, near, far, new Matrix4());
1479
1416
  }
1480
1417
  /**
1481
1418
  * Generate a look-at matrix. If you want a matrix that actually makes an object look at another object, use `targetTo` instead.
1482
1419
  * @param eye - The position of the viewer.
1483
1420
  * @param center - The point that the viewer is looking at.
1484
1421
  * @param up - The local up direction.
1485
- * @param out - The matrix to store the result in.
1486
1422
  * @returns The look-at matrix.
1487
1423
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1488
1424
  */
1489
- static lookAt(eye, center, up = [0, 1, 0], out = new Matrix4()) {
1490
- return lookAt(eye, center, up, out);
1425
+ static lookAt(eye, center, up = [0, 1, 0]) {
1426
+ return lookAt(eye, center, up, new Matrix4());
1491
1427
  }
1492
1428
  /**
1493
1429
  * Create a matrix that makes something look at something else.
1494
1430
  * @param eye - The position of the viewer.
1495
1431
  * @param target - The point that the viewer is looking at.
1496
1432
  * @param up - The local up direction.
1497
- * @param out - The matrix to store the result in.
1498
1433
  * @returns The transformation matrix.
1499
1434
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1500
1435
  */
1501
- static targetTo(eye, target, up = [0, 1, 0], out = new Matrix4()) {
1502
- return targetTo(eye, target, up, out);
1436
+ static targetTo(eye, target, up = [0, 1, 0]) {
1437
+ return targetTo(eye, target, up, new Matrix4());
1503
1438
  }
1504
1439
  /**
1505
1440
  * Create a two-by-two matrix with the given values.
@@ -1519,11 +1454,10 @@ export default class Matrix4 extends Float32Array {
1519
1454
  * @param c3r1 - The value in the fourth column and second row.
1520
1455
  * @param c3r2 - The value in the fourth column and third row.
1521
1456
  * @param c3r3 - The value in the fourth column and fourth row.
1522
- * @param out - The matrix to store the result in.
1523
1457
  * @returns The matrix.
1524
1458
  */
1525
- static fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3, out = new Matrix4()) {
1526
- return fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3, out);
1459
+ static fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3) {
1460
+ return fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3, new Matrix4());
1527
1461
  }
1528
1462
  /**
1529
1463
  * Create a four-by-four identity matrix.
@@ -1593,29 +1527,26 @@ export default class Matrix4 extends Float32Array {
1593
1527
  /**
1594
1528
  * Add two matrices of the same size.
1595
1529
  * @param matrix - The other matrix.
1596
- * @param out - The matrix to store the result in.
1597
1530
  * @returns The sum of the matrices.
1598
1531
  * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1599
1532
  */
1600
- add(matrix, out = new Matrix4()) {
1601
- return add(this, matrix, out);
1533
+ add(matrix) {
1534
+ return add(this, matrix, new Matrix4());
1602
1535
  }
1603
1536
  /**
1604
1537
  * Calculate the adjugate of this matrix.
1605
- * @param out - The matrix to store the result in.
1606
1538
  * @returns The adjugate of this matrix.
1607
1539
  * @see {@link https://en.wikipedia.org/wiki/Adjugate_matrix | Adjugate matrix}
1608
1540
  */
1609
- adjoint(out = new Matrix4()) {
1610
- return adjoint(this, out);
1541
+ adjoint() {
1542
+ return adjoint(this, new Matrix4());
1611
1543
  }
1612
1544
  /**
1613
1545
  * Copy the values from this matrix to another one.
1614
- * @param out - The matrix to store the result in.
1615
1546
  * @returns The copy.
1616
1547
  */
1617
- clone(out = new Matrix4()) {
1618
- return copy(this, out);
1548
+ clone() {
1549
+ return copy(this, new Matrix4());
1619
1550
  }
1620
1551
  /**
1621
1552
  * Copy the values of another matrix into this one.
@@ -1635,53 +1566,48 @@ export default class Matrix4 extends Float32Array {
1635
1566
  /**
1636
1567
  * Multiply this matrix by another.
1637
1568
  * @param matrix - The other matrix.
1638
- * @param out - The matrix to store the result in.
1639
1569
  * @returns The product of the matrices.
1640
1570
  * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1641
1571
  */
1642
- multiply(matrix, out = new Matrix4()) {
1643
- return multiply(this, matrix, out);
1572
+ multiply(matrix) {
1573
+ return multiply(this, matrix, new Matrix4());
1644
1574
  }
1645
1575
  /**
1646
1576
  * Multiply this matrix by a scalar value.
1647
1577
  * @param scalar - The scalar value.
1648
- * @param out - The matrix to store the result in.
1649
1578
  * @returns The product of the matrix and the scalar value.
1650
1579
  * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1651
1580
  */
1652
- multiplyScalar(scalar, out = new Matrix4()) {
1653
- return multiplyScalar(this, scalar, out);
1581
+ multiplyScalar(scalar) {
1582
+ return multiplyScalar(this, scalar, new Matrix4());
1654
1583
  }
1655
1584
  /**
1656
1585
  * Add this matrix to another after multiplying the other by a scalar.
1657
1586
  * @param matrix - The other matrix.
1658
1587
  * @param scalar - The scalar.
1659
- * @param out - The matrix to store the result in.
1660
1588
  * @returns The sum.
1661
1589
  * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1662
1590
  * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1663
1591
  */
1664
- multiplyScalarAndAdd(matrix, scalar, out = new Matrix4()) {
1665
- return multiplyScalarAndAdd(this, matrix, scalar, out);
1592
+ multiplyScalarAndAdd(matrix, scalar) {
1593
+ return multiplyScalarAndAdd(this, matrix, scalar, new Matrix4());
1666
1594
  }
1667
1595
  /**
1668
1596
  * Subtract another matrix from this one.
1669
1597
  * @param matrix - The other matrix.
1670
- * @param out - The matrix to store the result in.
1671
1598
  * @returns The difference between the matrices.
1672
1599
  * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1673
1600
  */
1674
- subtract(matrix, out = new Matrix4()) {
1675
- return subtract(this, matrix, out);
1601
+ subtract(matrix) {
1602
+ return subtract(this, matrix, new Matrix4());
1676
1603
  }
1677
1604
  /**
1678
1605
  * Transpose this matrix.
1679
- * @param out - The matrix to store the result in.
1680
1606
  * @returns The transpose of this matrix.
1681
1607
  * @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
1682
1608
  */
1683
- transpose(out = new Matrix4()) {
1684
- return transpose(this, out);
1609
+ transpose() {
1610
+ return transpose(this, new Matrix4());
1685
1611
  }
1686
1612
  /**
1687
1613
  * Get the determinant of this matrix.
@@ -1700,110 +1626,99 @@ export default class Matrix4 extends Float32Array {
1700
1626
  }
1701
1627
  /**
1702
1628
  * Invert this matrix.
1703
- * @param out - The matrix to store the result in.
1704
1629
  * @returns The inverted matrix.
1705
1630
  * @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
1706
1631
  */
1707
- invert(out = new Matrix4()) {
1708
- return invert(this, out);
1632
+ invert() {
1633
+ return invert(this, new Matrix4());
1709
1634
  }
1710
1635
  /**
1711
1636
  * Scale this matrix by the given vector.
1712
1637
  * @param vector - The scaling vector.
1713
- * @param out - The matrix to store the result in.
1714
1638
  * @returns The scaled matrix.
1715
1639
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1716
1640
  */
1717
- scale(vector, out = new Matrix4()) {
1718
- return scale(this, vector, out);
1641
+ scale(vector) {
1642
+ return scale(this, vector, new Matrix4());
1719
1643
  }
1720
1644
  /**
1721
1645
  * Translate this matrix by the given vector.
1722
1646
  * @param vector - The translation vector.
1723
- * @param out - The matrix to store the result in.
1724
1647
  * @returns The translated matrix.
1725
1648
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1726
1649
  */
1727
- translate(vector, out = new Matrix4()) {
1728
- return translate(this, vector, out);
1650
+ translate(vector) {
1651
+ return translate(this, vector, new Matrix4());
1729
1652
  }
1730
1653
  /**
1731
1654
  * Rotate this matrix by the given angle around the given axis.
1732
1655
  * @param r - The angle in radians.
1733
1656
  * @param axis - The axis.
1734
- * @param out - The matrix to store the result in.
1735
1657
  * @returns The rotated matrix.
1736
1658
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1737
1659
  */
1738
- rotate(r, axis, out = new Matrix4()) {
1739
- return rotate(this, r, axis, out);
1660
+ rotate(r, axis) {
1661
+ return rotate(this, r, axis, new Matrix4());
1740
1662
  }
1741
1663
  /**
1742
1664
  * Rotate this matrix by the given angle around the X-axis.
1743
1665
  * @param r - The angle in radians.
1744
- * @param out - The matrix to store the result in.
1745
1666
  * @returns The rotated matrix.
1746
1667
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1747
1668
  */
1748
- rotateX(r, out = new Matrix4()) {
1749
- return rotateX(this, r, out);
1669
+ rotateX(r) {
1670
+ return rotateX(this, r, new Matrix4());
1750
1671
  }
1751
1672
  /**
1752
1673
  * Rotate this matrix by the given angle around the Y-axis.
1753
1674
  * @param r - The angle in radians.
1754
- * @param out - The matrix to store the result in.
1755
1675
  * @returns The rotated matrix.
1756
1676
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1757
1677
  */
1758
- rotateY(r, out = new Matrix4()) {
1759
- return rotateY(this, r, out);
1678
+ rotateY(r) {
1679
+ return rotateY(this, r, new Matrix4());
1760
1680
  }
1761
1681
  /**
1762
1682
  * Rotate this matrix by the given angle around the Z-axis.
1763
1683
  * @param r - The angle in radians.
1764
- * @param out - The matrix to store the result in.
1765
1684
  * @returns The rotated matrix.
1766
1685
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1767
1686
  */
1768
- rotateZ(r, out = new Matrix4()) {
1769
- return rotateZ(this, r, out);
1687
+ rotateZ(r) {
1688
+ return rotateZ(this, r, new Matrix4());
1770
1689
  }
1771
1690
  /**
1772
1691
  * Get the translation vector component of this transformation matrix.
1773
- * @param out - The vector to store the result in.
1774
1692
  * @returns The translation.
1775
1693
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1776
1694
  */
1777
- getTranslation(out = new Vector3()) {
1778
- return getTranslation(this, out);
1695
+ getTranslation() {
1696
+ return getTranslation(this, new Vector3());
1779
1697
  }
1780
1698
  /**
1781
1699
  * Set the translation vector component of this transformation matrix.
1782
1700
  * @param translation - The translation vector.
1783
- * @param out - The matrix to store the result in.
1784
1701
  * @returns The transformation matrix.
1785
1702
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1786
1703
  */
1787
- setTranslation(translation, out = new Matrix4()) {
1788
- return setTranslation(this, translation, out);
1704
+ setTranslation(translation) {
1705
+ return setTranslation(this, translation, new Matrix4());
1789
1706
  }
1790
1707
  /**
1791
1708
  * Get the scaling vector component of this transformation matrix.
1792
- * @param out - The vector to store the result in.
1793
1709
  * @returns The scaling.
1794
1710
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1795
1711
  */
1796
- getScaling(out = new Vector3()) {
1797
- return getScaling(this, out);
1712
+ getScaling() {
1713
+ return getScaling(this, new Vector3());
1798
1714
  }
1799
1715
  /**
1800
1716
  * Get the scaling vector component of this transformation matrix.
1801
- * @param out - The quaternion to store the result in.
1802
1717
  * @returns The rotation.
1803
1718
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1804
1719
  */
1805
- getRotation(out = new Quaternion()) {
1806
- return getRotation(this, out);
1720
+ getRotation() {
1721
+ return getRotation(this, new Quaternion());
1807
1722
  }
1808
1723
  }
1809
1724
  //# sourceMappingURL=Matrix4.js.map