@ohif/app 3.10.0-beta.113 → 3.10.0-beta.115

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 (66) hide show
  1. package/dist/1568.bundle.af4308b321dfab0445e6.js +6562 -0
  2. package/dist/{1919.bundle.fae108d3c6ad35ed05ae.js → 1919.bundle.8bd683b21cbfe1cb71a7.js} +12 -8
  3. package/dist/1919.css +1 -1
  4. package/dist/{870.bundle.26a075bb828c43c13794.js → 2308.bundle.8db15bbd9d5833f21526.js} +54 -135
  5. package/dist/{870.css → 2308.css} +1 -1
  6. package/dist/{2701.bundle.c9ea5a2bd0df31dd3aaa.js → 2701.bundle.b68c4419910024a0758d.js} +14 -10
  7. package/dist/3480.bundle.22f8a106b17da4d7e826.js +7495 -0
  8. package/dist/{3677.bundle.22ecea02fae99fc4b073.js → 3677.bundle.4a319db2fd495efa4564.js} +1648 -1654
  9. package/dist/{5770.bundle.700382010763de7c58fd.js → 4113.bundle.8fccd7af6118fde173aa.js} +34 -80
  10. package/dist/{4202.bundle.add83801fbc8227d551b.js → 4202.bundle.c86958c59da67316127c.js} +1 -1
  11. package/dist/{4526.bundle.bf1047785c90ef0a9fec.js → 4526.bundle.7b394677fd5dc4fad06f.js} +6 -6
  12. package/dist/{99.bundle.f7e8de6d86029ec75605.js → 4675.bundle.b7e00e5915520885fa1f.js} +967 -2
  13. package/dist/4743.bundle.9faa6ddab058d9a939f4.js +6634 -0
  14. package/dist/{4759.bundle.0d60078f58f5a56c0157.js → 4759.bundle.e4ff22f9db3f555aad7b.js} +4 -0
  15. package/dist/4759.css +1 -1
  16. package/dist/{2236.bundle.2fbf9a607e380f3bdd7f.js → 4789.bundle.5bc2d9e5507319d9cadf.js} +22327 -22350
  17. package/dist/{4834.bundle.750ec176d0ef84772b0a.js → 4834.bundle.6b5e7e0fc3343ec1960a.js} +1 -1
  18. package/dist/{4991.bundle.aa561005b9bff1f391af.js → 4991.bundle.897fe8cb1e85dbf31543.js} +4 -0
  19. package/dist/5258.bundle.f95ab2e02467a734bdb6.js +4519 -0
  20. package/dist/{5915.bundle.84b8c2aa4d4a8c7e40a2.js → 5341.bundle.2f963b49a4856e342cd1.js} +48327 -48879
  21. package/dist/{5674.bundle.05e639d0871778c8093a.js → 5674.bundle.977cff87c10fbb29cbb3.js} +4 -0
  22. package/dist/5674.css +1 -1
  23. package/dist/{573.bundle.ae0bd4f3e1f4eac8ae43.js → 573.bundle.9549b3f7fa44438654f0.js} +1 -1
  24. package/dist/{6027.bundle.32be836eef7308434394.js → 6027.bundle.d85e8a6bae1085cda03e.js} +3 -5
  25. package/dist/{8888.bundle.f6a648dc743772c89787.js → 6139.bundle.12d9035382cda028683b.js} +26538 -32458
  26. package/dist/{6201.bundle.11e6c535543d13b0bb98.js → 6201.bundle.db75c77eb056cb88c2b0.js} +4 -4
  27. package/dist/6201.css +1 -1
  28. package/dist/{6341.bundle.5e868cc5104bc834fcbc.js → 6341.bundle.40ae99e784ab35e9407c.js} +11 -21
  29. package/dist/6341.css +1 -1
  30. package/dist/{5038.bundle.790dfe509bc9841701b0.js → 6727.bundle.ffc91186f23237ec35c4.js} +4022 -11619
  31. package/dist/{6734.bundle.1a6cfb006f9a16963b0d.js → 6734.bundle.6829e6ba782c290fb687.js} +2 -2
  32. package/dist/6734.css +1 -1
  33. package/dist/6752.bundle.e33e02dd8f006be51464.js +2249 -0
  34. package/dist/{7197.bundle.3503d1951304cac940fa.js → 7197.bundle.e8529fdc03c3cc927e38.js} +50 -41
  35. package/dist/7197.css +1 -1
  36. package/dist/{5692.bundle.22ae2ac093b6d6b65a6e.js → 7942.bundle.a76695b6bc780cbf0b23.js} +474 -513
  37. package/dist/{8008.bundle.74e51bdb02ff5d264f50.js → 8008.bundle.bbb188c7a9c5358b5682.js} +4 -9
  38. package/dist/{810.bundle.342fc8fac8ae665558c6.js → 810.bundle.e388d7b970d9622441c4.js} +10 -10
  39. package/dist/810.css +1 -1
  40. package/dist/{8228.bundle.4bcb42b49355447ef23c.js → 8228.bundle.9532c8d75799a8d9c093.js} +2 -2
  41. package/dist/{8259.bundle.39723f9c04717f80687e.js → 8259.bundle.0f474d990a129494e1df.js} +3 -3
  42. package/dist/8402.css +1 -1
  43. package/dist/{8558.bundle.56d667a6969a60bab102.js → 8558.bundle.ffb653dfb0104bdd128e.js} +5 -1
  44. package/dist/8834.bundle.88696f3afc37982b4273.js +14581 -0
  45. package/dist/{9026.bundle.90271a421048d1adc3db.js → 9026.bundle.317d3f9be65ef67b9bff.js} +15 -10
  46. package/dist/{9551.bundle.44d1426054e46cf5d673.js → 9551.bundle.92b13000deb4aa87f2fd.js} +4 -9
  47. package/dist/{9072.bundle.49293623f9ed4582eeeb.js → 9855.bundle.ba46a4315a78373262ad.js} +451 -393
  48. package/dist/{9862.bundle.a4ccc41bcff91a46d37e.js → 9862.bundle.e44946f8d28ded1e722f.js} +3 -3
  49. package/dist/{9890.bundle.07483064f31feb5718a4.js → 9890.bundle.711bf3486194cdd5c039.js} +6 -6
  50. package/dist/9890.css +1 -1
  51. package/dist/app-config.js +8 -1
  52. package/dist/{app.bundle.3dc9aa5b6077224cc394.js → app.bundle.aac0f76ff17b3e978aa1.js} +55160 -53512
  53. package/dist/app.bundle.css +2 -2
  54. package/dist/{polySeg.bundle.d41f5224f4efc124505a.js → compute.bundle.fa052dcf2ef82b4950ad.js} +4 -3
  55. package/dist/{histogram-worker.bundle.6b0dbbdb168d711efad4.js → histogram-worker.bundle.986106c30f091f2cef47.js} +2 -1
  56. package/dist/index.html +1 -1
  57. package/dist/polySeg.bundle.7d21e7dc9b361089e3a5.js +250 -0
  58. package/dist/{suv-peak-worker.bundle.4ca63044b76f51350d34.js → suv-peak-worker.bundle.f22f853b6599f7ec6f0c.js} +6 -5
  59. package/dist/sw.js +1 -1
  60. package/package.json +19 -19
  61. package/dist/2045.bundle.aaa10dff6d93bec47a45.js +0 -9708
  62. package/dist/6896.bundle.ca9b905abe733f279387.js +0 -7147
  63. /package/dist/{213.bundle.a98935570805e4a7b9b2.js → 213.bundle.533d331e72ec5aa85b1c.js} +0 -0
  64. /package/dist/{2424.bundle.4f1eeae6a8f248dd34c1.js → 2424.bundle.4f39ac6cdb1a28a0ded3.js} +0 -0
  65. /package/dist/{2825.bundle.a9ed7e8b46a92a157797.js → 2825.bundle.f6bfd4cc1a286ebb1b38.js} +0 -0
  66. /package/dist/{7955.bundle.eba45d4238f7e762545d.js → 7955.bundle.24dbe9de87056ecbb422.js} +0 -0
@@ -3009,7 +3009,7 @@ var Constants = {
3009
3009
  /* harmony import */ var _DataSet_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(69147);
3010
3010
  /* harmony import */ var _StructuredData_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(24964);
3011
3011
  /* harmony import */ var _StructuredData_Constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(85278);
3012
- /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3823);
3012
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(40230);
3013
3013
 
3014
3014
 
3015
3015
 
@@ -5300,2222 +5300,2216 @@ if (!Math.hypot) Math.hypot = function () {
5300
5300
 
5301
5301
  /***/ }),
5302
5302
 
5303
- /***/ 3823:
5303
+ /***/ 40230:
5304
5304
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5305
5305
 
5306
5306
  "use strict";
5307
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5308
+ /* harmony export */ eR: () => (/* reexport module object */ _vec3_js__WEBPACK_IMPORTED_MODULE_8__),
5309
+ /* harmony export */ pB: () => (/* reexport module object */ _mat4_js__WEBPACK_IMPORTED_MODULE_4__),
5310
+ /* harmony export */ w0: () => (/* reexport module object */ _mat3_js__WEBPACK_IMPORTED_MODULE_3__)
5311
+ /* harmony export */ });
5312
+ /* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24457);
5313
+ /* harmony import */ var _mat2_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(98232);
5314
+ /* harmony import */ var _mat2d_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(72918);
5315
+ /* harmony import */ var _mat3_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(32591);
5316
+ /* harmony import */ var _mat4_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(28910);
5317
+ /* harmony import */ var _quat_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(50095);
5318
+ /* harmony import */ var _quat2_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(16953);
5319
+ /* harmony import */ var _vec2_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(67872);
5320
+ /* harmony import */ var _vec3_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(9175);
5321
+ /* harmony import */ var _vec4_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(15958);
5307
5322
 
5308
- // EXPORTS
5309
- __webpack_require__.d(__webpack_exports__, {
5310
- w0: () => (/* reexport */ mat3),
5311
- pB: () => (/* reexport */ mat4),
5312
- eR: () => (/* reexport */ vec3)
5313
- });
5314
5323
 
5315
- // UNUSED EXPORTS: glMatrix, mat2, mat2d, quat, quat2, vec2, vec4
5316
-
5317
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/common.js
5318
- var common = __webpack_require__(24457);
5319
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/mat2.js
5320
- var mat2 = __webpack_require__(98232);
5321
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/mat2d.js
5322
- var mat2d = __webpack_require__(72918);
5323
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/mat3.js
5324
- var mat3 = __webpack_require__(32591);
5325
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/mat4.js
5326
- var mat4 = __webpack_require__(28910);
5327
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/quat.js
5328
- var quat = __webpack_require__(50095);
5329
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/quat2.js
5330
- var quat2 = __webpack_require__(16953);
5331
- ;// CONCATENATED MODULE: ../../../node_modules/gl-matrix/esm/vec2.js
5324
+
5325
+
5326
+
5327
+
5328
+
5329
+
5330
+
5331
+
5332
+
5333
+
5334
+ /***/ }),
5335
+
5336
+ /***/ 32591:
5337
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5338
+
5339
+ "use strict";
5340
+ __webpack_require__.r(__webpack_exports__);
5341
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5342
+ /* harmony export */ add: () => (/* binding */ add),
5343
+ /* harmony export */ adjoint: () => (/* binding */ adjoint),
5344
+ /* harmony export */ clone: () => (/* binding */ clone),
5345
+ /* harmony export */ copy: () => (/* binding */ copy),
5346
+ /* harmony export */ create: () => (/* binding */ create),
5347
+ /* harmony export */ determinant: () => (/* binding */ determinant),
5348
+ /* harmony export */ equals: () => (/* binding */ equals),
5349
+ /* harmony export */ exactEquals: () => (/* binding */ exactEquals),
5350
+ /* harmony export */ frob: () => (/* binding */ frob),
5351
+ /* harmony export */ fromMat2d: () => (/* binding */ fromMat2d),
5352
+ /* harmony export */ fromMat4: () => (/* binding */ fromMat4),
5353
+ /* harmony export */ fromQuat: () => (/* binding */ fromQuat),
5354
+ /* harmony export */ fromRotation: () => (/* binding */ fromRotation),
5355
+ /* harmony export */ fromScaling: () => (/* binding */ fromScaling),
5356
+ /* harmony export */ fromTranslation: () => (/* binding */ fromTranslation),
5357
+ /* harmony export */ fromValues: () => (/* binding */ fromValues),
5358
+ /* harmony export */ identity: () => (/* binding */ identity),
5359
+ /* harmony export */ invert: () => (/* binding */ invert),
5360
+ /* harmony export */ mul: () => (/* binding */ mul),
5361
+ /* harmony export */ multiply: () => (/* binding */ multiply),
5362
+ /* harmony export */ multiplyScalar: () => (/* binding */ multiplyScalar),
5363
+ /* harmony export */ multiplyScalarAndAdd: () => (/* binding */ multiplyScalarAndAdd),
5364
+ /* harmony export */ normalFromMat4: () => (/* binding */ normalFromMat4),
5365
+ /* harmony export */ projection: () => (/* binding */ projection),
5366
+ /* harmony export */ rotate: () => (/* binding */ rotate),
5367
+ /* harmony export */ scale: () => (/* binding */ scale),
5368
+ /* harmony export */ set: () => (/* binding */ set),
5369
+ /* harmony export */ str: () => (/* binding */ str),
5370
+ /* harmony export */ sub: () => (/* binding */ sub),
5371
+ /* harmony export */ subtract: () => (/* binding */ subtract),
5372
+ /* harmony export */ translate: () => (/* binding */ translate),
5373
+ /* harmony export */ transpose: () => (/* binding */ transpose)
5374
+ /* harmony export */ });
5375
+ /* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24457);
5332
5376
 
5333
5377
  /**
5334
- * 2 Dimensional Vector
5335
- * @module vec2
5378
+ * 3x3 Matrix
5379
+ * @module mat3
5336
5380
  */
5337
5381
 
5338
5382
  /**
5339
- * Creates a new, empty vec2
5383
+ * Creates a new identity mat3
5340
5384
  *
5341
- * @returns {vec2} a new 2D vector
5385
+ * @returns {mat3} a new 3x3 matrix
5342
5386
  */
5343
5387
 
5344
5388
  function create() {
5345
- var out = new common.ARRAY_TYPE(2);
5389
+ var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(9);
5346
5390
 
5347
- if (common.ARRAY_TYPE != Float32Array) {
5348
- out[0] = 0;
5391
+ if (_common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE != Float32Array) {
5349
5392
  out[1] = 0;
5393
+ out[2] = 0;
5394
+ out[3] = 0;
5395
+ out[5] = 0;
5396
+ out[6] = 0;
5397
+ out[7] = 0;
5350
5398
  }
5351
5399
 
5400
+ out[0] = 1;
5401
+ out[4] = 1;
5402
+ out[8] = 1;
5352
5403
  return out;
5353
5404
  }
5354
5405
  /**
5355
- * Creates a new vec2 initialized with values from an existing vector
5406
+ * Copies the upper-left 3x3 values into the given mat3.
5356
5407
  *
5357
- * @param {ReadonlyVec2} a vector to clone
5358
- * @returns {vec2} a new 2D vector
5408
+ * @param {mat3} out the receiving 3x3 matrix
5409
+ * @param {ReadonlyMat4} a the source 4x4 matrix
5410
+ * @returns {mat3} out
5359
5411
  */
5360
5412
 
5361
- function clone(a) {
5362
- var out = new glMatrix.ARRAY_TYPE(2);
5413
+ function fromMat4(out, a) {
5363
5414
  out[0] = a[0];
5364
5415
  out[1] = a[1];
5416
+ out[2] = a[2];
5417
+ out[3] = a[4];
5418
+ out[4] = a[5];
5419
+ out[5] = a[6];
5420
+ out[6] = a[8];
5421
+ out[7] = a[9];
5422
+ out[8] = a[10];
5365
5423
  return out;
5366
5424
  }
5367
5425
  /**
5368
- * Creates a new vec2 initialized with the given values
5426
+ * Creates a new mat3 initialized with values from an existing matrix
5369
5427
  *
5370
- * @param {Number} x X component
5371
- * @param {Number} y Y component
5372
- * @returns {vec2} a new 2D vector
5428
+ * @param {ReadonlyMat3} a matrix to clone
5429
+ * @returns {mat3} a new 3x3 matrix
5373
5430
  */
5374
5431
 
5375
- function fromValues(x, y) {
5376
- var out = new glMatrix.ARRAY_TYPE(2);
5377
- out[0] = x;
5378
- out[1] = y;
5432
+ function clone(a) {
5433
+ var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(9);
5434
+ out[0] = a[0];
5435
+ out[1] = a[1];
5436
+ out[2] = a[2];
5437
+ out[3] = a[3];
5438
+ out[4] = a[4];
5439
+ out[5] = a[5];
5440
+ out[6] = a[6];
5441
+ out[7] = a[7];
5442
+ out[8] = a[8];
5379
5443
  return out;
5380
5444
  }
5381
5445
  /**
5382
- * Copy the values from one vec2 to another
5446
+ * Copy the values from one mat3 to another
5383
5447
  *
5384
- * @param {vec2} out the receiving vector
5385
- * @param {ReadonlyVec2} a the source vector
5386
- * @returns {vec2} out
5448
+ * @param {mat3} out the receiving matrix
5449
+ * @param {ReadonlyMat3} a the source matrix
5450
+ * @returns {mat3} out
5387
5451
  */
5388
5452
 
5389
5453
  function copy(out, a) {
5390
5454
  out[0] = a[0];
5391
5455
  out[1] = a[1];
5456
+ out[2] = a[2];
5457
+ out[3] = a[3];
5458
+ out[4] = a[4];
5459
+ out[5] = a[5];
5460
+ out[6] = a[6];
5461
+ out[7] = a[7];
5462
+ out[8] = a[8];
5392
5463
  return out;
5393
5464
  }
5394
5465
  /**
5395
- * Set the components of a vec2 to the given values
5466
+ * Create a new mat3 with the given values
5396
5467
  *
5397
- * @param {vec2} out the receiving vector
5398
- * @param {Number} x X component
5399
- * @param {Number} y Y component
5400
- * @returns {vec2} out
5468
+ * @param {Number} m00 Component in column 0, row 0 position (index 0)
5469
+ * @param {Number} m01 Component in column 0, row 1 position (index 1)
5470
+ * @param {Number} m02 Component in column 0, row 2 position (index 2)
5471
+ * @param {Number} m10 Component in column 1, row 0 position (index 3)
5472
+ * @param {Number} m11 Component in column 1, row 1 position (index 4)
5473
+ * @param {Number} m12 Component in column 1, row 2 position (index 5)
5474
+ * @param {Number} m20 Component in column 2, row 0 position (index 6)
5475
+ * @param {Number} m21 Component in column 2, row 1 position (index 7)
5476
+ * @param {Number} m22 Component in column 2, row 2 position (index 8)
5477
+ * @returns {mat3} A new mat3
5401
5478
  */
5402
5479
 
5403
- function set(out, x, y) {
5404
- out[0] = x;
5405
- out[1] = y;
5480
+ function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
5481
+ var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(9);
5482
+ out[0] = m00;
5483
+ out[1] = m01;
5484
+ out[2] = m02;
5485
+ out[3] = m10;
5486
+ out[4] = m11;
5487
+ out[5] = m12;
5488
+ out[6] = m20;
5489
+ out[7] = m21;
5490
+ out[8] = m22;
5406
5491
  return out;
5407
5492
  }
5408
5493
  /**
5409
- * Adds two vec2's
5494
+ * Set the components of a mat3 to the given values
5410
5495
  *
5411
- * @param {vec2} out the receiving vector
5412
- * @param {ReadonlyVec2} a the first operand
5413
- * @param {ReadonlyVec2} b the second operand
5414
- * @returns {vec2} out
5496
+ * @param {mat3} out the receiving matrix
5497
+ * @param {Number} m00 Component in column 0, row 0 position (index 0)
5498
+ * @param {Number} m01 Component in column 0, row 1 position (index 1)
5499
+ * @param {Number} m02 Component in column 0, row 2 position (index 2)
5500
+ * @param {Number} m10 Component in column 1, row 0 position (index 3)
5501
+ * @param {Number} m11 Component in column 1, row 1 position (index 4)
5502
+ * @param {Number} m12 Component in column 1, row 2 position (index 5)
5503
+ * @param {Number} m20 Component in column 2, row 0 position (index 6)
5504
+ * @param {Number} m21 Component in column 2, row 1 position (index 7)
5505
+ * @param {Number} m22 Component in column 2, row 2 position (index 8)
5506
+ * @returns {mat3} out
5415
5507
  */
5416
5508
 
5417
- function add(out, a, b) {
5418
- out[0] = a[0] + b[0];
5419
- out[1] = a[1] + b[1];
5509
+ function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
5510
+ out[0] = m00;
5511
+ out[1] = m01;
5512
+ out[2] = m02;
5513
+ out[3] = m10;
5514
+ out[4] = m11;
5515
+ out[5] = m12;
5516
+ out[6] = m20;
5517
+ out[7] = m21;
5518
+ out[8] = m22;
5420
5519
  return out;
5421
5520
  }
5422
5521
  /**
5423
- * Subtracts vector b from vector a
5522
+ * Set a mat3 to the identity matrix
5424
5523
  *
5425
- * @param {vec2} out the receiving vector
5426
- * @param {ReadonlyVec2} a the first operand
5427
- * @param {ReadonlyVec2} b the second operand
5428
- * @returns {vec2} out
5524
+ * @param {mat3} out the receiving matrix
5525
+ * @returns {mat3} out
5429
5526
  */
5430
5527
 
5431
- function subtract(out, a, b) {
5432
- out[0] = a[0] - b[0];
5433
- out[1] = a[1] - b[1];
5528
+ function identity(out) {
5529
+ out[0] = 1;
5530
+ out[1] = 0;
5531
+ out[2] = 0;
5532
+ out[3] = 0;
5533
+ out[4] = 1;
5534
+ out[5] = 0;
5535
+ out[6] = 0;
5536
+ out[7] = 0;
5537
+ out[8] = 1;
5434
5538
  return out;
5435
5539
  }
5436
5540
  /**
5437
- * Multiplies two vec2's
5541
+ * Transpose the values of a mat3
5438
5542
  *
5439
- * @param {vec2} out the receiving vector
5440
- * @param {ReadonlyVec2} a the first operand
5441
- * @param {ReadonlyVec2} b the second operand
5442
- * @returns {vec2} out
5543
+ * @param {mat3} out the receiving matrix
5544
+ * @param {ReadonlyMat3} a the source matrix
5545
+ * @returns {mat3} out
5443
5546
  */
5444
5547
 
5445
- function multiply(out, a, b) {
5446
- out[0] = a[0] * b[0];
5447
- out[1] = a[1] * b[1];
5548
+ function transpose(out, a) {
5549
+ // If we are transposing ourselves we can skip a few steps but have to cache some values
5550
+ if (out === a) {
5551
+ var a01 = a[1],
5552
+ a02 = a[2],
5553
+ a12 = a[5];
5554
+ out[1] = a[3];
5555
+ out[2] = a[6];
5556
+ out[3] = a01;
5557
+ out[5] = a[7];
5558
+ out[6] = a02;
5559
+ out[7] = a12;
5560
+ } else {
5561
+ out[0] = a[0];
5562
+ out[1] = a[3];
5563
+ out[2] = a[6];
5564
+ out[3] = a[1];
5565
+ out[4] = a[4];
5566
+ out[5] = a[7];
5567
+ out[6] = a[2];
5568
+ out[7] = a[5];
5569
+ out[8] = a[8];
5570
+ }
5571
+
5448
5572
  return out;
5449
5573
  }
5450
5574
  /**
5451
- * Divides two vec2's
5575
+ * Inverts a mat3
5452
5576
  *
5453
- * @param {vec2} out the receiving vector
5454
- * @param {ReadonlyVec2} a the first operand
5455
- * @param {ReadonlyVec2} b the second operand
5456
- * @returns {vec2} out
5577
+ * @param {mat3} out the receiving matrix
5578
+ * @param {ReadonlyMat3} a the source matrix
5579
+ * @returns {mat3} out
5457
5580
  */
5458
5581
 
5459
- function divide(out, a, b) {
5460
- out[0] = a[0] / b[0];
5461
- out[1] = a[1] / b[1];
5582
+ function invert(out, a) {
5583
+ var a00 = a[0],
5584
+ a01 = a[1],
5585
+ a02 = a[2];
5586
+ var a10 = a[3],
5587
+ a11 = a[4],
5588
+ a12 = a[5];
5589
+ var a20 = a[6],
5590
+ a21 = a[7],
5591
+ a22 = a[8];
5592
+ var b01 = a22 * a11 - a12 * a21;
5593
+ var b11 = -a22 * a10 + a12 * a20;
5594
+ var b21 = a21 * a10 - a11 * a20; // Calculate the determinant
5595
+
5596
+ var det = a00 * b01 + a01 * b11 + a02 * b21;
5597
+
5598
+ if (!det) {
5599
+ return null;
5600
+ }
5601
+
5602
+ det = 1.0 / det;
5603
+ out[0] = b01 * det;
5604
+ out[1] = (-a22 * a01 + a02 * a21) * det;
5605
+ out[2] = (a12 * a01 - a02 * a11) * det;
5606
+ out[3] = b11 * det;
5607
+ out[4] = (a22 * a00 - a02 * a20) * det;
5608
+ out[5] = (-a12 * a00 + a02 * a10) * det;
5609
+ out[6] = b21 * det;
5610
+ out[7] = (-a21 * a00 + a01 * a20) * det;
5611
+ out[8] = (a11 * a00 - a01 * a10) * det;
5462
5612
  return out;
5463
5613
  }
5464
5614
  /**
5465
- * Math.ceil the components of a vec2
5615
+ * Calculates the adjugate of a mat3
5466
5616
  *
5467
- * @param {vec2} out the receiving vector
5468
- * @param {ReadonlyVec2} a vector to ceil
5469
- * @returns {vec2} out
5617
+ * @param {mat3} out the receiving matrix
5618
+ * @param {ReadonlyMat3} a the source matrix
5619
+ * @returns {mat3} out
5470
5620
  */
5471
5621
 
5472
- function ceil(out, a) {
5473
- out[0] = Math.ceil(a[0]);
5474
- out[1] = Math.ceil(a[1]);
5622
+ function adjoint(out, a) {
5623
+ var a00 = a[0],
5624
+ a01 = a[1],
5625
+ a02 = a[2];
5626
+ var a10 = a[3],
5627
+ a11 = a[4],
5628
+ a12 = a[5];
5629
+ var a20 = a[6],
5630
+ a21 = a[7],
5631
+ a22 = a[8];
5632
+ out[0] = a11 * a22 - a12 * a21;
5633
+ out[1] = a02 * a21 - a01 * a22;
5634
+ out[2] = a01 * a12 - a02 * a11;
5635
+ out[3] = a12 * a20 - a10 * a22;
5636
+ out[4] = a00 * a22 - a02 * a20;
5637
+ out[5] = a02 * a10 - a00 * a12;
5638
+ out[6] = a10 * a21 - a11 * a20;
5639
+ out[7] = a01 * a20 - a00 * a21;
5640
+ out[8] = a00 * a11 - a01 * a10;
5475
5641
  return out;
5476
5642
  }
5477
5643
  /**
5478
- * Math.floor the components of a vec2
5644
+ * Calculates the determinant of a mat3
5479
5645
  *
5480
- * @param {vec2} out the receiving vector
5481
- * @param {ReadonlyVec2} a vector to floor
5482
- * @returns {vec2} out
5646
+ * @param {ReadonlyMat3} a the source matrix
5647
+ * @returns {Number} determinant of a
5483
5648
  */
5484
5649
 
5485
- function floor(out, a) {
5486
- out[0] = Math.floor(a[0]);
5487
- out[1] = Math.floor(a[1]);
5488
- return out;
5650
+ function determinant(a) {
5651
+ var a00 = a[0],
5652
+ a01 = a[1],
5653
+ a02 = a[2];
5654
+ var a10 = a[3],
5655
+ a11 = a[4],
5656
+ a12 = a[5];
5657
+ var a20 = a[6],
5658
+ a21 = a[7],
5659
+ a22 = a[8];
5660
+ return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
5489
5661
  }
5490
5662
  /**
5491
- * Returns the minimum of two vec2's
5663
+ * Multiplies two mat3's
5492
5664
  *
5493
- * @param {vec2} out the receiving vector
5494
- * @param {ReadonlyVec2} a the first operand
5495
- * @param {ReadonlyVec2} b the second operand
5496
- * @returns {vec2} out
5665
+ * @param {mat3} out the receiving matrix
5666
+ * @param {ReadonlyMat3} a the first operand
5667
+ * @param {ReadonlyMat3} b the second operand
5668
+ * @returns {mat3} out
5497
5669
  */
5498
5670
 
5499
- function min(out, a, b) {
5500
- out[0] = Math.min(a[0], b[0]);
5501
- out[1] = Math.min(a[1], b[1]);
5671
+ function multiply(out, a, b) {
5672
+ var a00 = a[0],
5673
+ a01 = a[1],
5674
+ a02 = a[2];
5675
+ var a10 = a[3],
5676
+ a11 = a[4],
5677
+ a12 = a[5];
5678
+ var a20 = a[6],
5679
+ a21 = a[7],
5680
+ a22 = a[8];
5681
+ var b00 = b[0],
5682
+ b01 = b[1],
5683
+ b02 = b[2];
5684
+ var b10 = b[3],
5685
+ b11 = b[4],
5686
+ b12 = b[5];
5687
+ var b20 = b[6],
5688
+ b21 = b[7],
5689
+ b22 = b[8];
5690
+ out[0] = b00 * a00 + b01 * a10 + b02 * a20;
5691
+ out[1] = b00 * a01 + b01 * a11 + b02 * a21;
5692
+ out[2] = b00 * a02 + b01 * a12 + b02 * a22;
5693
+ out[3] = b10 * a00 + b11 * a10 + b12 * a20;
5694
+ out[4] = b10 * a01 + b11 * a11 + b12 * a21;
5695
+ out[5] = b10 * a02 + b11 * a12 + b12 * a22;
5696
+ out[6] = b20 * a00 + b21 * a10 + b22 * a20;
5697
+ out[7] = b20 * a01 + b21 * a11 + b22 * a21;
5698
+ out[8] = b20 * a02 + b21 * a12 + b22 * a22;
5502
5699
  return out;
5503
5700
  }
5504
5701
  /**
5505
- * Returns the maximum of two vec2's
5702
+ * Translate a mat3 by the given vector
5506
5703
  *
5507
- * @param {vec2} out the receiving vector
5508
- * @param {ReadonlyVec2} a the first operand
5509
- * @param {ReadonlyVec2} b the second operand
5510
- * @returns {vec2} out
5704
+ * @param {mat3} out the receiving matrix
5705
+ * @param {ReadonlyMat3} a the matrix to translate
5706
+ * @param {ReadonlyVec2} v vector to translate by
5707
+ * @returns {mat3} out
5511
5708
  */
5512
5709
 
5513
- function max(out, a, b) {
5514
- out[0] = Math.max(a[0], b[0]);
5515
- out[1] = Math.max(a[1], b[1]);
5710
+ function translate(out, a, v) {
5711
+ var a00 = a[0],
5712
+ a01 = a[1],
5713
+ a02 = a[2],
5714
+ a10 = a[3],
5715
+ a11 = a[4],
5716
+ a12 = a[5],
5717
+ a20 = a[6],
5718
+ a21 = a[7],
5719
+ a22 = a[8],
5720
+ x = v[0],
5721
+ y = v[1];
5722
+ out[0] = a00;
5723
+ out[1] = a01;
5724
+ out[2] = a02;
5725
+ out[3] = a10;
5726
+ out[4] = a11;
5727
+ out[5] = a12;
5728
+ out[6] = x * a00 + y * a10 + a20;
5729
+ out[7] = x * a01 + y * a11 + a21;
5730
+ out[8] = x * a02 + y * a12 + a22;
5516
5731
  return out;
5517
5732
  }
5518
5733
  /**
5519
- * Math.round the components of a vec2
5734
+ * Rotates a mat3 by the given angle
5520
5735
  *
5521
- * @param {vec2} out the receiving vector
5522
- * @param {ReadonlyVec2} a vector to round
5523
- * @returns {vec2} out
5736
+ * @param {mat3} out the receiving matrix
5737
+ * @param {ReadonlyMat3} a the matrix to rotate
5738
+ * @param {Number} rad the angle to rotate the matrix by
5739
+ * @returns {mat3} out
5524
5740
  */
5525
5741
 
5526
- function round(out, a) {
5527
- out[0] = Math.round(a[0]);
5528
- out[1] = Math.round(a[1]);
5742
+ function rotate(out, a, rad) {
5743
+ var a00 = a[0],
5744
+ a01 = a[1],
5745
+ a02 = a[2],
5746
+ a10 = a[3],
5747
+ a11 = a[4],
5748
+ a12 = a[5],
5749
+ a20 = a[6],
5750
+ a21 = a[7],
5751
+ a22 = a[8],
5752
+ s = Math.sin(rad),
5753
+ c = Math.cos(rad);
5754
+ out[0] = c * a00 + s * a10;
5755
+ out[1] = c * a01 + s * a11;
5756
+ out[2] = c * a02 + s * a12;
5757
+ out[3] = c * a10 - s * a00;
5758
+ out[4] = c * a11 - s * a01;
5759
+ out[5] = c * a12 - s * a02;
5760
+ out[6] = a20;
5761
+ out[7] = a21;
5762
+ out[8] = a22;
5529
5763
  return out;
5530
5764
  }
5531
5765
  /**
5532
- * Scales a vec2 by a scalar number
5766
+ * Scales the mat3 by the dimensions in the given vec2
5533
5767
  *
5534
- * @param {vec2} out the receiving vector
5535
- * @param {ReadonlyVec2} a the vector to scale
5536
- * @param {Number} b amount to scale the vector by
5537
- * @returns {vec2} out
5538
- */
5768
+ * @param {mat3} out the receiving matrix
5769
+ * @param {ReadonlyMat3} a the matrix to rotate
5770
+ * @param {ReadonlyVec2} v the vec2 to scale the matrix by
5771
+ * @returns {mat3} out
5772
+ **/
5539
5773
 
5540
- function scale(out, a, b) {
5541
- out[0] = a[0] * b;
5542
- out[1] = a[1] * b;
5774
+ function scale(out, a, v) {
5775
+ var x = v[0],
5776
+ y = v[1];
5777
+ out[0] = x * a[0];
5778
+ out[1] = x * a[1];
5779
+ out[2] = x * a[2];
5780
+ out[3] = y * a[3];
5781
+ out[4] = y * a[4];
5782
+ out[5] = y * a[5];
5783
+ out[6] = a[6];
5784
+ out[7] = a[7];
5785
+ out[8] = a[8];
5543
5786
  return out;
5544
5787
  }
5545
5788
  /**
5546
- * Adds two vec2's after scaling the second operand by a scalar value
5789
+ * Creates a matrix from a vector translation
5790
+ * This is equivalent to (but much faster than):
5547
5791
  *
5548
- * @param {vec2} out the receiving vector
5549
- * @param {ReadonlyVec2} a the first operand
5550
- * @param {ReadonlyVec2} b the second operand
5551
- * @param {Number} scale the amount to scale b by before adding
5552
- * @returns {vec2} out
5792
+ * mat3.identity(dest);
5793
+ * mat3.translate(dest, dest, vec);
5794
+ *
5795
+ * @param {mat3} out mat3 receiving operation result
5796
+ * @param {ReadonlyVec2} v Translation vector
5797
+ * @returns {mat3} out
5553
5798
  */
5554
5799
 
5555
- function scaleAndAdd(out, a, b, scale) {
5556
- out[0] = a[0] + b[0] * scale;
5557
- out[1] = a[1] + b[1] * scale;
5800
+ function fromTranslation(out, v) {
5801
+ out[0] = 1;
5802
+ out[1] = 0;
5803
+ out[2] = 0;
5804
+ out[3] = 0;
5805
+ out[4] = 1;
5806
+ out[5] = 0;
5807
+ out[6] = v[0];
5808
+ out[7] = v[1];
5809
+ out[8] = 1;
5558
5810
  return out;
5559
5811
  }
5560
5812
  /**
5561
- * Calculates the euclidian distance between two vec2's
5813
+ * Creates a matrix from a given angle
5814
+ * This is equivalent to (but much faster than):
5562
5815
  *
5563
- * @param {ReadonlyVec2} a the first operand
5564
- * @param {ReadonlyVec2} b the second operand
5565
- * @returns {Number} distance between a and b
5566
- */
5567
-
5568
- function distance(a, b) {
5569
- var x = b[0] - a[0],
5570
- y = b[1] - a[1];
5571
- return Math.hypot(x, y);
5572
- }
5573
- /**
5574
- * Calculates the squared euclidian distance between two vec2's
5816
+ * mat3.identity(dest);
5817
+ * mat3.rotate(dest, dest, rad);
5575
5818
  *
5576
- * @param {ReadonlyVec2} a the first operand
5577
- * @param {ReadonlyVec2} b the second operand
5578
- * @returns {Number} squared distance between a and b
5819
+ * @param {mat3} out mat3 receiving operation result
5820
+ * @param {Number} rad the angle to rotate the matrix by
5821
+ * @returns {mat3} out
5579
5822
  */
5580
5823
 
5581
- function squaredDistance(a, b) {
5582
- var x = b[0] - a[0],
5583
- y = b[1] - a[1];
5584
- return x * x + y * y;
5824
+ function fromRotation(out, rad) {
5825
+ var s = Math.sin(rad),
5826
+ c = Math.cos(rad);
5827
+ out[0] = c;
5828
+ out[1] = s;
5829
+ out[2] = 0;
5830
+ out[3] = -s;
5831
+ out[4] = c;
5832
+ out[5] = 0;
5833
+ out[6] = 0;
5834
+ out[7] = 0;
5835
+ out[8] = 1;
5836
+ return out;
5585
5837
  }
5586
5838
  /**
5587
- * Calculates the length of a vec2
5839
+ * Creates a matrix from a vector scaling
5840
+ * This is equivalent to (but much faster than):
5588
5841
  *
5589
- * @param {ReadonlyVec2} a vector to calculate length of
5590
- * @returns {Number} length of a
5591
- */
5592
-
5593
- function vec2_length(a) {
5594
- var x = a[0],
5595
- y = a[1];
5596
- return Math.hypot(x, y);
5597
- }
5598
- /**
5599
- * Calculates the squared length of a vec2
5842
+ * mat3.identity(dest);
5843
+ * mat3.scale(dest, dest, vec);
5600
5844
  *
5601
- * @param {ReadonlyVec2} a vector to calculate squared length of
5602
- * @returns {Number} squared length of a
5845
+ * @param {mat3} out mat3 receiving operation result
5846
+ * @param {ReadonlyVec2} v Scaling vector
5847
+ * @returns {mat3} out
5603
5848
  */
5604
5849
 
5605
- function squaredLength(a) {
5606
- var x = a[0],
5607
- y = a[1];
5608
- return x * x + y * y;
5850
+ function fromScaling(out, v) {
5851
+ out[0] = v[0];
5852
+ out[1] = 0;
5853
+ out[2] = 0;
5854
+ out[3] = 0;
5855
+ out[4] = v[1];
5856
+ out[5] = 0;
5857
+ out[6] = 0;
5858
+ out[7] = 0;
5859
+ out[8] = 1;
5860
+ return out;
5609
5861
  }
5610
5862
  /**
5611
- * Negates the components of a vec2
5863
+ * Copies the values from a mat2d into a mat3
5612
5864
  *
5613
- * @param {vec2} out the receiving vector
5614
- * @param {ReadonlyVec2} a vector to negate
5615
- * @returns {vec2} out
5616
- */
5865
+ * @param {mat3} out the receiving matrix
5866
+ * @param {ReadonlyMat2d} a the matrix to copy
5867
+ * @returns {mat3} out
5868
+ **/
5617
5869
 
5618
- function negate(out, a) {
5619
- out[0] = -a[0];
5620
- out[1] = -a[1];
5870
+ function fromMat2d(out, a) {
5871
+ out[0] = a[0];
5872
+ out[1] = a[1];
5873
+ out[2] = 0;
5874
+ out[3] = a[2];
5875
+ out[4] = a[3];
5876
+ out[5] = 0;
5877
+ out[6] = a[4];
5878
+ out[7] = a[5];
5879
+ out[8] = 1;
5621
5880
  return out;
5622
5881
  }
5623
5882
  /**
5624
- * Returns the inverse of the components of a vec2
5883
+ * Calculates a 3x3 matrix from the given quaternion
5625
5884
  *
5626
- * @param {vec2} out the receiving vector
5627
- * @param {ReadonlyVec2} a vector to invert
5628
- * @returns {vec2} out
5885
+ * @param {mat3} out mat3 receiving operation result
5886
+ * @param {ReadonlyQuat} q Quaternion to create matrix from
5887
+ *
5888
+ * @returns {mat3} out
5629
5889
  */
5630
5890
 
5631
- function inverse(out, a) {
5632
- out[0] = 1.0 / a[0];
5633
- out[1] = 1.0 / a[1];
5891
+ function fromQuat(out, q) {
5892
+ var x = q[0],
5893
+ y = q[1],
5894
+ z = q[2],
5895
+ w = q[3];
5896
+ var x2 = x + x;
5897
+ var y2 = y + y;
5898
+ var z2 = z + z;
5899
+ var xx = x * x2;
5900
+ var yx = y * x2;
5901
+ var yy = y * y2;
5902
+ var zx = z * x2;
5903
+ var zy = z * y2;
5904
+ var zz = z * z2;
5905
+ var wx = w * x2;
5906
+ var wy = w * y2;
5907
+ var wz = w * z2;
5908
+ out[0] = 1 - yy - zz;
5909
+ out[3] = yx - wz;
5910
+ out[6] = zx + wy;
5911
+ out[1] = yx + wz;
5912
+ out[4] = 1 - xx - zz;
5913
+ out[7] = zy - wx;
5914
+ out[2] = zx - wy;
5915
+ out[5] = zy + wx;
5916
+ out[8] = 1 - xx - yy;
5634
5917
  return out;
5635
5918
  }
5636
5919
  /**
5637
- * Normalize a vec2
5920
+ * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
5638
5921
  *
5639
- * @param {vec2} out the receiving vector
5640
- * @param {ReadonlyVec2} a vector to normalize
5641
- * @returns {vec2} out
5922
+ * @param {mat3} out mat3 receiving operation result
5923
+ * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from
5924
+ *
5925
+ * @returns {mat3} out
5642
5926
  */
5643
5927
 
5644
- function normalize(out, a) {
5645
- var x = a[0],
5646
- y = a[1];
5647
- var len = x * x + y * y;
5928
+ function normalFromMat4(out, a) {
5929
+ var a00 = a[0],
5930
+ a01 = a[1],
5931
+ a02 = a[2],
5932
+ a03 = a[3];
5933
+ var a10 = a[4],
5934
+ a11 = a[5],
5935
+ a12 = a[6],
5936
+ a13 = a[7];
5937
+ var a20 = a[8],
5938
+ a21 = a[9],
5939
+ a22 = a[10],
5940
+ a23 = a[11];
5941
+ var a30 = a[12],
5942
+ a31 = a[13],
5943
+ a32 = a[14],
5944
+ a33 = a[15];
5945
+ var b00 = a00 * a11 - a01 * a10;
5946
+ var b01 = a00 * a12 - a02 * a10;
5947
+ var b02 = a00 * a13 - a03 * a10;
5948
+ var b03 = a01 * a12 - a02 * a11;
5949
+ var b04 = a01 * a13 - a03 * a11;
5950
+ var b05 = a02 * a13 - a03 * a12;
5951
+ var b06 = a20 * a31 - a21 * a30;
5952
+ var b07 = a20 * a32 - a22 * a30;
5953
+ var b08 = a20 * a33 - a23 * a30;
5954
+ var b09 = a21 * a32 - a22 * a31;
5955
+ var b10 = a21 * a33 - a23 * a31;
5956
+ var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
5648
5957
 
5649
- if (len > 0) {
5650
- //TODO: evaluate use of glm_invsqrt here?
5651
- len = 1 / Math.sqrt(len);
5958
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
5959
+
5960
+ if (!det) {
5961
+ return null;
5652
5962
  }
5653
5963
 
5654
- out[0] = a[0] * len;
5655
- out[1] = a[1] * len;
5964
+ det = 1.0 / det;
5965
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
5966
+ out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
5967
+ out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
5968
+ out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
5969
+ out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
5970
+ out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
5971
+ out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
5972
+ out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
5973
+ out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
5656
5974
  return out;
5657
5975
  }
5658
5976
  /**
5659
- * Calculates the dot product of two vec2's
5977
+ * Generates a 2D projection matrix with the given bounds
5660
5978
  *
5661
- * @param {ReadonlyVec2} a the first operand
5662
- * @param {ReadonlyVec2} b the second operand
5663
- * @returns {Number} dot product of a and b
5979
+ * @param {mat3} out mat3 frustum matrix will be written into
5980
+ * @param {number} width Width of your gl context
5981
+ * @param {number} height Height of gl context
5982
+ * @returns {mat3} out
5664
5983
  */
5665
5984
 
5666
- function dot(a, b) {
5667
- return a[0] * b[0] + a[1] * b[1];
5985
+ function projection(out, width, height) {
5986
+ out[0] = 2 / width;
5987
+ out[1] = 0;
5988
+ out[2] = 0;
5989
+ out[3] = 0;
5990
+ out[4] = -2 / height;
5991
+ out[5] = 0;
5992
+ out[6] = -1;
5993
+ out[7] = 1;
5994
+ out[8] = 1;
5995
+ return out;
5668
5996
  }
5669
5997
  /**
5670
- * Computes the cross product of two vec2's
5671
- * Note that the cross product must by definition produce a 3D vector
5998
+ * Returns a string representation of a mat3
5672
5999
  *
5673
- * @param {vec3} out the receiving vector
5674
- * @param {ReadonlyVec2} a the first operand
5675
- * @param {ReadonlyVec2} b the second operand
5676
- * @returns {vec3} out
6000
+ * @param {ReadonlyMat3} a matrix to represent as a string
6001
+ * @returns {String} string representation of the matrix
5677
6002
  */
5678
6003
 
5679
- function cross(out, a, b) {
5680
- var z = a[0] * b[1] - a[1] * b[0];
5681
- out[0] = out[1] = 0;
5682
- out[2] = z;
5683
- return out;
6004
+ function str(a) {
6005
+ return "mat3(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ")";
5684
6006
  }
5685
6007
  /**
5686
- * Performs a linear interpolation between two vec2's
6008
+ * Returns Frobenius norm of a mat3
5687
6009
  *
5688
- * @param {vec2} out the receiving vector
5689
- * @param {ReadonlyVec2} a the first operand
5690
- * @param {ReadonlyVec2} b the second operand
5691
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
5692
- * @returns {vec2} out
6010
+ * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of
6011
+ * @returns {Number} Frobenius norm
5693
6012
  */
5694
6013
 
5695
- function lerp(out, a, b, t) {
5696
- var ax = a[0],
5697
- ay = a[1];
5698
- out[0] = ax + t * (b[0] - ax);
5699
- out[1] = ay + t * (b[1] - ay);
5700
- return out;
6014
+ function frob(a) {
6015
+ return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
5701
6016
  }
5702
6017
  /**
5703
- * Generates a random vector with the given scale
6018
+ * Adds two mat3's
5704
6019
  *
5705
- * @param {vec2} out the receiving vector
5706
- * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
5707
- * @returns {vec2} out
6020
+ * @param {mat3} out the receiving matrix
6021
+ * @param {ReadonlyMat3} a the first operand
6022
+ * @param {ReadonlyMat3} b the second operand
6023
+ * @returns {mat3} out
5708
6024
  */
5709
6025
 
5710
- function random(out, scale) {
5711
- scale = scale || 1.0;
5712
- var r = glMatrix.RANDOM() * 2.0 * Math.PI;
5713
- out[0] = Math.cos(r) * scale;
5714
- out[1] = Math.sin(r) * scale;
5715
- return out;
5716
- }
5717
- /**
5718
- * Transforms the vec2 with a mat2
5719
- *
5720
- * @param {vec2} out the receiving vector
5721
- * @param {ReadonlyVec2} a the vector to transform
5722
- * @param {ReadonlyMat2} m matrix to transform with
5723
- * @returns {vec2} out
5724
- */
5725
-
5726
- function transformMat2(out, a, m) {
5727
- var x = a[0],
5728
- y = a[1];
5729
- out[0] = m[0] * x + m[2] * y;
5730
- out[1] = m[1] * x + m[3] * y;
5731
- return out;
5732
- }
5733
- /**
5734
- * Transforms the vec2 with a mat2d
5735
- *
5736
- * @param {vec2} out the receiving vector
5737
- * @param {ReadonlyVec2} a the vector to transform
5738
- * @param {ReadonlyMat2d} m matrix to transform with
5739
- * @returns {vec2} out
5740
- */
5741
-
5742
- function transformMat2d(out, a, m) {
5743
- var x = a[0],
5744
- y = a[1];
5745
- out[0] = m[0] * x + m[2] * y + m[4];
5746
- out[1] = m[1] * x + m[3] * y + m[5];
6026
+ function add(out, a, b) {
6027
+ out[0] = a[0] + b[0];
6028
+ out[1] = a[1] + b[1];
6029
+ out[2] = a[2] + b[2];
6030
+ out[3] = a[3] + b[3];
6031
+ out[4] = a[4] + b[4];
6032
+ out[5] = a[5] + b[5];
6033
+ out[6] = a[6] + b[6];
6034
+ out[7] = a[7] + b[7];
6035
+ out[8] = a[8] + b[8];
5747
6036
  return out;
5748
6037
  }
5749
6038
  /**
5750
- * Transforms the vec2 with a mat3
5751
- * 3rd vector component is implicitly '1'
6039
+ * Subtracts matrix b from matrix a
5752
6040
  *
5753
- * @param {vec2} out the receiving vector
5754
- * @param {ReadonlyVec2} a the vector to transform
5755
- * @param {ReadonlyMat3} m matrix to transform with
5756
- * @returns {vec2} out
6041
+ * @param {mat3} out the receiving matrix
6042
+ * @param {ReadonlyMat3} a the first operand
6043
+ * @param {ReadonlyMat3} b the second operand
6044
+ * @returns {mat3} out
5757
6045
  */
5758
6046
 
5759
- function transformMat3(out, a, m) {
5760
- var x = a[0],
5761
- y = a[1];
5762
- out[0] = m[0] * x + m[3] * y + m[6];
5763
- out[1] = m[1] * x + m[4] * y + m[7];
6047
+ function subtract(out, a, b) {
6048
+ out[0] = a[0] - b[0];
6049
+ out[1] = a[1] - b[1];
6050
+ out[2] = a[2] - b[2];
6051
+ out[3] = a[3] - b[3];
6052
+ out[4] = a[4] - b[4];
6053
+ out[5] = a[5] - b[5];
6054
+ out[6] = a[6] - b[6];
6055
+ out[7] = a[7] - b[7];
6056
+ out[8] = a[8] - b[8];
5764
6057
  return out;
5765
6058
  }
5766
6059
  /**
5767
- * Transforms the vec2 with a mat4
5768
- * 3rd vector component is implicitly '0'
5769
- * 4th vector component is implicitly '1'
6060
+ * Multiply each element of the matrix by a scalar.
5770
6061
  *
5771
- * @param {vec2} out the receiving vector
5772
- * @param {ReadonlyVec2} a the vector to transform
5773
- * @param {ReadonlyMat4} m matrix to transform with
5774
- * @returns {vec2} out
5775
- */
5776
-
5777
- function transformMat4(out, a, m) {
5778
- var x = a[0];
5779
- var y = a[1];
5780
- out[0] = m[0] * x + m[4] * y + m[12];
5781
- out[1] = m[1] * x + m[5] * y + m[13];
5782
- return out;
5783
- }
5784
- /**
5785
- * Rotate a 2D vector
5786
- * @param {vec2} out The receiving vec2
5787
- * @param {ReadonlyVec2} a The vec2 point to rotate
5788
- * @param {ReadonlyVec2} b The origin of the rotation
5789
- * @param {Number} rad The angle of rotation in radians
5790
- * @returns {vec2} out
6062
+ * @param {mat3} out the receiving matrix
6063
+ * @param {ReadonlyMat3} a the matrix to scale
6064
+ * @param {Number} b amount to scale the matrix's elements by
6065
+ * @returns {mat3} out
5791
6066
  */
5792
6067
 
5793
- function rotate(out, a, b, rad) {
5794
- //Translate point to the origin
5795
- var p0 = a[0] - b[0],
5796
- p1 = a[1] - b[1],
5797
- sinC = Math.sin(rad),
5798
- cosC = Math.cos(rad); //perform rotation and translate to correct position
5799
-
5800
- out[0] = p0 * cosC - p1 * sinC + b[0];
5801
- out[1] = p0 * sinC + p1 * cosC + b[1];
6068
+ function multiplyScalar(out, a, b) {
6069
+ out[0] = a[0] * b;
6070
+ out[1] = a[1] * b;
6071
+ out[2] = a[2] * b;
6072
+ out[3] = a[3] * b;
6073
+ out[4] = a[4] * b;
6074
+ out[5] = a[5] * b;
6075
+ out[6] = a[6] * b;
6076
+ out[7] = a[7] * b;
6077
+ out[8] = a[8] * b;
5802
6078
  return out;
5803
6079
  }
5804
6080
  /**
5805
- * Get the angle between two 2D vectors
5806
- * @param {ReadonlyVec2} a The first operand
5807
- * @param {ReadonlyVec2} b The second operand
5808
- * @returns {Number} The angle in radians
5809
- */
5810
-
5811
- function angle(a, b) {
5812
- var x1 = a[0],
5813
- y1 = a[1],
5814
- x2 = b[0],
5815
- y2 = b[1],
5816
- // mag is the product of the magnitudes of a and b
5817
- mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2),
5818
- // mag &&.. short circuits if mag == 0
5819
- cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1
5820
-
5821
- return Math.acos(Math.min(Math.max(cosine, -1), 1));
5822
- }
5823
- /**
5824
- * Set the components of a vec2 to zero
6081
+ * Adds two mat3's after multiplying each element of the second operand by a scalar value.
5825
6082
  *
5826
- * @param {vec2} out the receiving vector
5827
- * @returns {vec2} out
6083
+ * @param {mat3} out the receiving vector
6084
+ * @param {ReadonlyMat3} a the first operand
6085
+ * @param {ReadonlyMat3} b the second operand
6086
+ * @param {Number} scale the amount to scale b's elements by before adding
6087
+ * @returns {mat3} out
5828
6088
  */
5829
6089
 
5830
- function zero(out) {
5831
- out[0] = 0.0;
5832
- out[1] = 0.0;
6090
+ function multiplyScalarAndAdd(out, a, b, scale) {
6091
+ out[0] = a[0] + b[0] * scale;
6092
+ out[1] = a[1] + b[1] * scale;
6093
+ out[2] = a[2] + b[2] * scale;
6094
+ out[3] = a[3] + b[3] * scale;
6095
+ out[4] = a[4] + b[4] * scale;
6096
+ out[5] = a[5] + b[5] * scale;
6097
+ out[6] = a[6] + b[6] * scale;
6098
+ out[7] = a[7] + b[7] * scale;
6099
+ out[8] = a[8] + b[8] * scale;
5833
6100
  return out;
5834
6101
  }
5835
6102
  /**
5836
- * Returns a string representation of a vector
5837
- *
5838
- * @param {ReadonlyVec2} a vector to represent as a string
5839
- * @returns {String} string representation of the vector
5840
- */
5841
-
5842
- function str(a) {
5843
- return "vec2(" + a[0] + ", " + a[1] + ")";
5844
- }
5845
- /**
5846
- * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
6103
+ * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
5847
6104
  *
5848
- * @param {ReadonlyVec2} a The first vector.
5849
- * @param {ReadonlyVec2} b The second vector.
5850
- * @returns {Boolean} True if the vectors are equal, false otherwise.
6105
+ * @param {ReadonlyMat3} a The first matrix.
6106
+ * @param {ReadonlyMat3} b The second matrix.
6107
+ * @returns {Boolean} True if the matrices are equal, false otherwise.
5851
6108
  */
5852
6109
 
5853
6110
  function exactEquals(a, b) {
5854
- return a[0] === b[0] && a[1] === b[1];
6111
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
5855
6112
  }
5856
6113
  /**
5857
- * Returns whether or not the vectors have approximately the same elements in the same position.
6114
+ * Returns whether or not the matrices have approximately the same elements in the same position.
5858
6115
  *
5859
- * @param {ReadonlyVec2} a The first vector.
5860
- * @param {ReadonlyVec2} b The second vector.
5861
- * @returns {Boolean} True if the vectors are equal, false otherwise.
6116
+ * @param {ReadonlyMat3} a The first matrix.
6117
+ * @param {ReadonlyMat3} b The second matrix.
6118
+ * @returns {Boolean} True if the matrices are equal, false otherwise.
5862
6119
  */
5863
6120
 
5864
6121
  function equals(a, b) {
5865
6122
  var a0 = a[0],
5866
- a1 = a[1];
6123
+ a1 = a[1],
6124
+ a2 = a[2],
6125
+ a3 = a[3],
6126
+ a4 = a[4],
6127
+ a5 = a[5],
6128
+ a6 = a[6],
6129
+ a7 = a[7],
6130
+ a8 = a[8];
5867
6131
  var b0 = b[0],
5868
- b1 = b[1];
5869
- return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));
6132
+ b1 = b[1],
6133
+ b2 = b[2],
6134
+ b3 = b[3],
6135
+ b4 = b[4],
6136
+ b5 = b[5],
6137
+ b6 = b[6],
6138
+ b7 = b[7],
6139
+ b8 = b[8];
6140
+ return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
5870
6141
  }
5871
6142
  /**
5872
- * Alias for {@link vec2.length}
6143
+ * Alias for {@link mat3.multiply}
5873
6144
  * @function
5874
6145
  */
5875
6146
 
5876
- var len = (/* unused pure expression or super */ null && (vec2_length));
6147
+ var mul = multiply;
5877
6148
  /**
5878
- * Alias for {@link vec2.subtract}
6149
+ * Alias for {@link mat3.subtract}
5879
6150
  * @function
5880
6151
  */
5881
6152
 
5882
- var sub = (/* unused pure expression or super */ null && (subtract));
5883
- /**
5884
- * Alias for {@link vec2.multiply}
5885
- * @function
5886
- */
6153
+ var sub = subtract;
6154
+
6155
+ /***/ }),
6156
+
6157
+ /***/ 50095:
6158
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6159
+
6160
+ "use strict";
6161
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6162
+ /* harmony export */ copy: () => (/* binding */ copy),
6163
+ /* harmony export */ dot: () => (/* binding */ dot),
6164
+ /* harmony export */ length: () => (/* binding */ length),
6165
+ /* harmony export */ squaredLength: () => (/* binding */ squaredLength)
6166
+ /* harmony export */ });
6167
+ /* unused harmony exports create, identity, setAxisAngle, getAxisAngle, getAngle, multiply, rotateX, rotateY, rotateZ, calculateW, exp, ln, pow, slerp, random, invert, conjugate, fromMat3, fromEuler, str, clone, fromValues, set, add, mul, scale, lerp, len, sqrLen, normalize, exactEquals, equals, rotationTo, sqlerp, setAxes */
6168
+ /* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24457);
6169
+ /* harmony import */ var _mat3_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(32591);
6170
+ /* harmony import */ var _vec3_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9175);
6171
+ /* harmony import */ var _vec4_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15958);
5887
6172
 
5888
- var mul = (/* unused pure expression or super */ null && (multiply));
5889
- /**
5890
- * Alias for {@link vec2.divide}
5891
- * @function
5892
- */
5893
6173
 
5894
- var div = (/* unused pure expression or super */ null && (divide));
5895
- /**
5896
- * Alias for {@link vec2.distance}
5897
- * @function
5898
- */
5899
6174
 
5900
- var dist = (/* unused pure expression or super */ null && (distance));
5901
- /**
5902
- * Alias for {@link vec2.squaredDistance}
5903
- * @function
5904
- */
5905
6175
 
5906
- var sqrDist = (/* unused pure expression or super */ null && (squaredDistance));
5907
6176
  /**
5908
- * Alias for {@link vec2.squaredLength}
5909
- * @function
6177
+ * Quaternion
6178
+ * @module quat
5910
6179
  */
5911
6180
 
5912
- var sqrLen = (/* unused pure expression or super */ null && (squaredLength));
5913
6181
  /**
5914
- * Perform some operation over an array of vec2s.
6182
+ * Creates a new identity quat
5915
6183
  *
5916
- * @param {Array} a the array of vectors to iterate over
5917
- * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
5918
- * @param {Number} offset Number of elements to skip at the beginning of the array
5919
- * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
5920
- * @param {Function} fn Function to call for each vector in the array
5921
- * @param {Object} [arg] additional argument to pass to fn
5922
- * @returns {Array} a
5923
- * @function
5924
- */
5925
-
5926
- var forEach = function () {
5927
- var vec = create();
5928
- return function (a, stride, offset, count, fn, arg) {
5929
- var i, l;
5930
-
5931
- if (!stride) {
5932
- stride = 2;
5933
- }
5934
-
5935
- if (!offset) {
5936
- offset = 0;
5937
- }
5938
-
5939
- if (count) {
5940
- l = Math.min(count * stride + offset, a.length);
5941
- } else {
5942
- l = a.length;
5943
- }
5944
-
5945
- for (i = offset; i < l; i += stride) {
5946
- vec[0] = a[i];
5947
- vec[1] = a[i + 1];
5948
- fn(vec, vec, arg);
5949
- a[i] = vec[0];
5950
- a[i + 1] = vec[1];
5951
- }
5952
-
5953
- return a;
5954
- };
5955
- }();
5956
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/vec3.js
5957
- var vec3 = __webpack_require__(9175);
5958
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/vec4.js
5959
- var vec4 = __webpack_require__(15958);
5960
- ;// CONCATENATED MODULE: ../../../node_modules/gl-matrix/esm/index.js
5961
-
5962
-
5963
-
5964
-
5965
-
5966
-
5967
-
5968
-
5969
-
5970
-
5971
-
5972
-
5973
- /***/ }),
5974
-
5975
- /***/ 32591:
5976
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5977
-
5978
- "use strict";
5979
- __webpack_require__.r(__webpack_exports__);
5980
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5981
- /* harmony export */ add: () => (/* binding */ add),
5982
- /* harmony export */ adjoint: () => (/* binding */ adjoint),
5983
- /* harmony export */ clone: () => (/* binding */ clone),
5984
- /* harmony export */ copy: () => (/* binding */ copy),
5985
- /* harmony export */ create: () => (/* binding */ create),
5986
- /* harmony export */ determinant: () => (/* binding */ determinant),
5987
- /* harmony export */ equals: () => (/* binding */ equals),
5988
- /* harmony export */ exactEquals: () => (/* binding */ exactEquals),
5989
- /* harmony export */ frob: () => (/* binding */ frob),
5990
- /* harmony export */ fromMat2d: () => (/* binding */ fromMat2d),
5991
- /* harmony export */ fromMat4: () => (/* binding */ fromMat4),
5992
- /* harmony export */ fromQuat: () => (/* binding */ fromQuat),
5993
- /* harmony export */ fromRotation: () => (/* binding */ fromRotation),
5994
- /* harmony export */ fromScaling: () => (/* binding */ fromScaling),
5995
- /* harmony export */ fromTranslation: () => (/* binding */ fromTranslation),
5996
- /* harmony export */ fromValues: () => (/* binding */ fromValues),
5997
- /* harmony export */ identity: () => (/* binding */ identity),
5998
- /* harmony export */ invert: () => (/* binding */ invert),
5999
- /* harmony export */ mul: () => (/* binding */ mul),
6000
- /* harmony export */ multiply: () => (/* binding */ multiply),
6001
- /* harmony export */ multiplyScalar: () => (/* binding */ multiplyScalar),
6002
- /* harmony export */ multiplyScalarAndAdd: () => (/* binding */ multiplyScalarAndAdd),
6003
- /* harmony export */ normalFromMat4: () => (/* binding */ normalFromMat4),
6004
- /* harmony export */ projection: () => (/* binding */ projection),
6005
- /* harmony export */ rotate: () => (/* binding */ rotate),
6006
- /* harmony export */ scale: () => (/* binding */ scale),
6007
- /* harmony export */ set: () => (/* binding */ set),
6008
- /* harmony export */ str: () => (/* binding */ str),
6009
- /* harmony export */ sub: () => (/* binding */ sub),
6010
- /* harmony export */ subtract: () => (/* binding */ subtract),
6011
- /* harmony export */ translate: () => (/* binding */ translate),
6012
- /* harmony export */ transpose: () => (/* binding */ transpose)
6013
- /* harmony export */ });
6014
- /* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24457);
6015
-
6016
- /**
6017
- * 3x3 Matrix
6018
- * @module mat3
6019
- */
6020
-
6021
- /**
6022
- * Creates a new identity mat3
6023
- *
6024
- * @returns {mat3} a new 3x3 matrix
6184
+ * @returns {quat} a new quaternion
6025
6185
  */
6026
6186
 
6027
6187
  function create() {
6028
- var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(9);
6188
+ var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(4);
6029
6189
 
6030
6190
  if (_common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE != Float32Array) {
6191
+ out[0] = 0;
6031
6192
  out[1] = 0;
6032
6193
  out[2] = 0;
6033
- out[3] = 0;
6034
- out[5] = 0;
6035
- out[6] = 0;
6036
- out[7] = 0;
6037
6194
  }
6038
6195
 
6039
- out[0] = 1;
6040
- out[4] = 1;
6041
- out[8] = 1;
6196
+ out[3] = 1;
6042
6197
  return out;
6043
6198
  }
6044
6199
  /**
6045
- * Copies the upper-left 3x3 values into the given mat3.
6200
+ * Set a quat to the identity quaternion
6046
6201
  *
6047
- * @param {mat3} out the receiving 3x3 matrix
6048
- * @param {ReadonlyMat4} a the source 4x4 matrix
6049
- * @returns {mat3} out
6202
+ * @param {quat} out the receiving quaternion
6203
+ * @returns {quat} out
6050
6204
  */
6051
6205
 
6052
- function fromMat4(out, a) {
6053
- out[0] = a[0];
6054
- out[1] = a[1];
6055
- out[2] = a[2];
6056
- out[3] = a[4];
6057
- out[4] = a[5];
6058
- out[5] = a[6];
6059
- out[6] = a[8];
6060
- out[7] = a[9];
6061
- out[8] = a[10];
6206
+ function identity(out) {
6207
+ out[0] = 0;
6208
+ out[1] = 0;
6209
+ out[2] = 0;
6210
+ out[3] = 1;
6062
6211
  return out;
6063
6212
  }
6064
6213
  /**
6065
- * Creates a new mat3 initialized with values from an existing matrix
6214
+ * Sets a quat from the given angle and rotation axis,
6215
+ * then returns it.
6066
6216
  *
6067
- * @param {ReadonlyMat3} a matrix to clone
6068
- * @returns {mat3} a new 3x3 matrix
6069
- */
6217
+ * @param {quat} out the receiving quaternion
6218
+ * @param {ReadonlyVec3} axis the axis around which to rotate
6219
+ * @param {Number} rad the angle in radians
6220
+ * @returns {quat} out
6221
+ **/
6070
6222
 
6071
- function clone(a) {
6072
- var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(9);
6073
- out[0] = a[0];
6074
- out[1] = a[1];
6075
- out[2] = a[2];
6076
- out[3] = a[3];
6077
- out[4] = a[4];
6078
- out[5] = a[5];
6079
- out[6] = a[6];
6080
- out[7] = a[7];
6081
- out[8] = a[8];
6223
+ function setAxisAngle(out, axis, rad) {
6224
+ rad = rad * 0.5;
6225
+ var s = Math.sin(rad);
6226
+ out[0] = s * axis[0];
6227
+ out[1] = s * axis[1];
6228
+ out[2] = s * axis[2];
6229
+ out[3] = Math.cos(rad);
6082
6230
  return out;
6083
6231
  }
6084
6232
  /**
6085
- * Copy the values from one mat3 to another
6086
- *
6087
- * @param {mat3} out the receiving matrix
6088
- * @param {ReadonlyMat3} a the source matrix
6089
- * @returns {mat3} out
6233
+ * Gets the rotation axis and angle for a given
6234
+ * quaternion. If a quaternion is created with
6235
+ * setAxisAngle, this method will return the same
6236
+ * values as providied in the original parameter list
6237
+ * OR functionally equivalent values.
6238
+ * Example: The quaternion formed by axis [0, 0, 1] and
6239
+ * angle -90 is the same as the quaternion formed by
6240
+ * [0, 0, 1] and 270. This method favors the latter.
6241
+ * @param {vec3} out_axis Vector receiving the axis of rotation
6242
+ * @param {ReadonlyQuat} q Quaternion to be decomposed
6243
+ * @return {Number} Angle, in radians, of the rotation
6090
6244
  */
6091
6245
 
6092
- function copy(out, a) {
6093
- out[0] = a[0];
6094
- out[1] = a[1];
6095
- out[2] = a[2];
6096
- out[3] = a[3];
6097
- out[4] = a[4];
6098
- out[5] = a[5];
6099
- out[6] = a[6];
6100
- out[7] = a[7];
6101
- out[8] = a[8];
6102
- return out;
6246
+ function getAxisAngle(out_axis, q) {
6247
+ var rad = Math.acos(q[3]) * 2.0;
6248
+ var s = Math.sin(rad / 2.0);
6249
+
6250
+ if (s > glMatrix.EPSILON) {
6251
+ out_axis[0] = q[0] / s;
6252
+ out_axis[1] = q[1] / s;
6253
+ out_axis[2] = q[2] / s;
6254
+ } else {
6255
+ // If s is zero, return any axis (no rotation - axis does not matter)
6256
+ out_axis[0] = 1;
6257
+ out_axis[1] = 0;
6258
+ out_axis[2] = 0;
6259
+ }
6260
+
6261
+ return rad;
6103
6262
  }
6104
6263
  /**
6105
- * Create a new mat3 with the given values
6264
+ * Gets the angular distance between two unit quaternions
6106
6265
  *
6107
- * @param {Number} m00 Component in column 0, row 0 position (index 0)
6108
- * @param {Number} m01 Component in column 0, row 1 position (index 1)
6109
- * @param {Number} m02 Component in column 0, row 2 position (index 2)
6110
- * @param {Number} m10 Component in column 1, row 0 position (index 3)
6111
- * @param {Number} m11 Component in column 1, row 1 position (index 4)
6112
- * @param {Number} m12 Component in column 1, row 2 position (index 5)
6113
- * @param {Number} m20 Component in column 2, row 0 position (index 6)
6114
- * @param {Number} m21 Component in column 2, row 1 position (index 7)
6115
- * @param {Number} m22 Component in column 2, row 2 position (index 8)
6116
- * @returns {mat3} A new mat3
6266
+ * @param {ReadonlyQuat} a Origin unit quaternion
6267
+ * @param {ReadonlyQuat} b Destination unit quaternion
6268
+ * @return {Number} Angle, in radians, between the two quaternions
6117
6269
  */
6118
6270
 
6119
- function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
6120
- var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(9);
6121
- out[0] = m00;
6122
- out[1] = m01;
6123
- out[2] = m02;
6124
- out[3] = m10;
6125
- out[4] = m11;
6126
- out[5] = m12;
6127
- out[6] = m20;
6128
- out[7] = m21;
6129
- out[8] = m22;
6130
- return out;
6271
+ function getAngle(a, b) {
6272
+ var dotproduct = dot(a, b);
6273
+ return Math.acos(2 * dotproduct * dotproduct - 1);
6131
6274
  }
6132
6275
  /**
6133
- * Set the components of a mat3 to the given values
6276
+ * Multiplies two quat's
6134
6277
  *
6135
- * @param {mat3} out the receiving matrix
6136
- * @param {Number} m00 Component in column 0, row 0 position (index 0)
6137
- * @param {Number} m01 Component in column 0, row 1 position (index 1)
6138
- * @param {Number} m02 Component in column 0, row 2 position (index 2)
6139
- * @param {Number} m10 Component in column 1, row 0 position (index 3)
6140
- * @param {Number} m11 Component in column 1, row 1 position (index 4)
6141
- * @param {Number} m12 Component in column 1, row 2 position (index 5)
6142
- * @param {Number} m20 Component in column 2, row 0 position (index 6)
6143
- * @param {Number} m21 Component in column 2, row 1 position (index 7)
6144
- * @param {Number} m22 Component in column 2, row 2 position (index 8)
6145
- * @returns {mat3} out
6146
- */
6147
-
6148
- function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
6149
- out[0] = m00;
6150
- out[1] = m01;
6151
- out[2] = m02;
6152
- out[3] = m10;
6153
- out[4] = m11;
6154
- out[5] = m12;
6155
- out[6] = m20;
6156
- out[7] = m21;
6157
- out[8] = m22;
6278
+ * @param {quat} out the receiving quaternion
6279
+ * @param {ReadonlyQuat} a the first operand
6280
+ * @param {ReadonlyQuat} b the second operand
6281
+ * @returns {quat} out
6282
+ */
6283
+
6284
+ function multiply(out, a, b) {
6285
+ var ax = a[0],
6286
+ ay = a[1],
6287
+ az = a[2],
6288
+ aw = a[3];
6289
+ var bx = b[0],
6290
+ by = b[1],
6291
+ bz = b[2],
6292
+ bw = b[3];
6293
+ out[0] = ax * bw + aw * bx + ay * bz - az * by;
6294
+ out[1] = ay * bw + aw * by + az * bx - ax * bz;
6295
+ out[2] = az * bw + aw * bz + ax * by - ay * bx;
6296
+ out[3] = aw * bw - ax * bx - ay * by - az * bz;
6158
6297
  return out;
6159
6298
  }
6160
6299
  /**
6161
- * Set a mat3 to the identity matrix
6300
+ * Rotates a quaternion by the given angle about the X axis
6162
6301
  *
6163
- * @param {mat3} out the receiving matrix
6164
- * @returns {mat3} out
6302
+ * @param {quat} out quat receiving operation result
6303
+ * @param {ReadonlyQuat} a quat to rotate
6304
+ * @param {number} rad angle (in radians) to rotate
6305
+ * @returns {quat} out
6165
6306
  */
6166
6307
 
6167
- function identity(out) {
6168
- out[0] = 1;
6169
- out[1] = 0;
6170
- out[2] = 0;
6171
- out[3] = 0;
6172
- out[4] = 1;
6173
- out[5] = 0;
6174
- out[6] = 0;
6175
- out[7] = 0;
6176
- out[8] = 1;
6308
+ function rotateX(out, a, rad) {
6309
+ rad *= 0.5;
6310
+ var ax = a[0],
6311
+ ay = a[1],
6312
+ az = a[2],
6313
+ aw = a[3];
6314
+ var bx = Math.sin(rad),
6315
+ bw = Math.cos(rad);
6316
+ out[0] = ax * bw + aw * bx;
6317
+ out[1] = ay * bw + az * bx;
6318
+ out[2] = az * bw - ay * bx;
6319
+ out[3] = aw * bw - ax * bx;
6177
6320
  return out;
6178
6321
  }
6179
6322
  /**
6180
- * Transpose the values of a mat3
6323
+ * Rotates a quaternion by the given angle about the Y axis
6181
6324
  *
6182
- * @param {mat3} out the receiving matrix
6183
- * @param {ReadonlyMat3} a the source matrix
6184
- * @returns {mat3} out
6325
+ * @param {quat} out quat receiving operation result
6326
+ * @param {ReadonlyQuat} a quat to rotate
6327
+ * @param {number} rad angle (in radians) to rotate
6328
+ * @returns {quat} out
6185
6329
  */
6186
6330
 
6187
- function transpose(out, a) {
6188
- // If we are transposing ourselves we can skip a few steps but have to cache some values
6189
- if (out === a) {
6190
- var a01 = a[1],
6191
- a02 = a[2],
6192
- a12 = a[5];
6193
- out[1] = a[3];
6194
- out[2] = a[6];
6195
- out[3] = a01;
6196
- out[5] = a[7];
6197
- out[6] = a02;
6198
- out[7] = a12;
6199
- } else {
6200
- out[0] = a[0];
6201
- out[1] = a[3];
6202
- out[2] = a[6];
6203
- out[3] = a[1];
6204
- out[4] = a[4];
6205
- out[5] = a[7];
6206
- out[6] = a[2];
6207
- out[7] = a[5];
6208
- out[8] = a[8];
6209
- }
6210
-
6331
+ function rotateY(out, a, rad) {
6332
+ rad *= 0.5;
6333
+ var ax = a[0],
6334
+ ay = a[1],
6335
+ az = a[2],
6336
+ aw = a[3];
6337
+ var by = Math.sin(rad),
6338
+ bw = Math.cos(rad);
6339
+ out[0] = ax * bw - az * by;
6340
+ out[1] = ay * bw + aw * by;
6341
+ out[2] = az * bw + ax * by;
6342
+ out[3] = aw * bw - ay * by;
6211
6343
  return out;
6212
6344
  }
6213
6345
  /**
6214
- * Inverts a mat3
6346
+ * Rotates a quaternion by the given angle about the Z axis
6215
6347
  *
6216
- * @param {mat3} out the receiving matrix
6217
- * @param {ReadonlyMat3} a the source matrix
6218
- * @returns {mat3} out
6348
+ * @param {quat} out quat receiving operation result
6349
+ * @param {ReadonlyQuat} a quat to rotate
6350
+ * @param {number} rad angle (in radians) to rotate
6351
+ * @returns {quat} out
6219
6352
  */
6220
6353
 
6221
- function invert(out, a) {
6222
- var a00 = a[0],
6223
- a01 = a[1],
6224
- a02 = a[2];
6225
- var a10 = a[3],
6226
- a11 = a[4],
6227
- a12 = a[5];
6228
- var a20 = a[6],
6229
- a21 = a[7],
6230
- a22 = a[8];
6231
- var b01 = a22 * a11 - a12 * a21;
6232
- var b11 = -a22 * a10 + a12 * a20;
6233
- var b21 = a21 * a10 - a11 * a20; // Calculate the determinant
6234
-
6235
- var det = a00 * b01 + a01 * b11 + a02 * b21;
6236
-
6237
- if (!det) {
6238
- return null;
6239
- }
6354
+ function rotateZ(out, a, rad) {
6355
+ rad *= 0.5;
6356
+ var ax = a[0],
6357
+ ay = a[1],
6358
+ az = a[2],
6359
+ aw = a[3];
6360
+ var bz = Math.sin(rad),
6361
+ bw = Math.cos(rad);
6362
+ out[0] = ax * bw + ay * bz;
6363
+ out[1] = ay * bw - ax * bz;
6364
+ out[2] = az * bw + aw * bz;
6365
+ out[3] = aw * bw - az * bz;
6366
+ return out;
6367
+ }
6368
+ /**
6369
+ * Calculates the W component of a quat from the X, Y, and Z components.
6370
+ * Assumes that quaternion is 1 unit in length.
6371
+ * Any existing W component will be ignored.
6372
+ *
6373
+ * @param {quat} out the receiving quaternion
6374
+ * @param {ReadonlyQuat} a quat to calculate W component of
6375
+ * @returns {quat} out
6376
+ */
6240
6377
 
6241
- det = 1.0 / det;
6242
- out[0] = b01 * det;
6243
- out[1] = (-a22 * a01 + a02 * a21) * det;
6244
- out[2] = (a12 * a01 - a02 * a11) * det;
6245
- out[3] = b11 * det;
6246
- out[4] = (a22 * a00 - a02 * a20) * det;
6247
- out[5] = (-a12 * a00 + a02 * a10) * det;
6248
- out[6] = b21 * det;
6249
- out[7] = (-a21 * a00 + a01 * a20) * det;
6250
- out[8] = (a11 * a00 - a01 * a10) * det;
6378
+ function calculateW(out, a) {
6379
+ var x = a[0],
6380
+ y = a[1],
6381
+ z = a[2];
6382
+ out[0] = x;
6383
+ out[1] = y;
6384
+ out[2] = z;
6385
+ out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));
6251
6386
  return out;
6252
6387
  }
6253
6388
  /**
6254
- * Calculates the adjugate of a mat3
6389
+ * Calculate the exponential of a unit quaternion.
6255
6390
  *
6256
- * @param {mat3} out the receiving matrix
6257
- * @param {ReadonlyMat3} a the source matrix
6258
- * @returns {mat3} out
6391
+ * @param {quat} out the receiving quaternion
6392
+ * @param {ReadonlyQuat} a quat to calculate the exponential of
6393
+ * @returns {quat} out
6259
6394
  */
6260
6395
 
6261
- function adjoint(out, a) {
6262
- var a00 = a[0],
6263
- a01 = a[1],
6264
- a02 = a[2];
6265
- var a10 = a[3],
6266
- a11 = a[4],
6267
- a12 = a[5];
6268
- var a20 = a[6],
6269
- a21 = a[7],
6270
- a22 = a[8];
6271
- out[0] = a11 * a22 - a12 * a21;
6272
- out[1] = a02 * a21 - a01 * a22;
6273
- out[2] = a01 * a12 - a02 * a11;
6274
- out[3] = a12 * a20 - a10 * a22;
6275
- out[4] = a00 * a22 - a02 * a20;
6276
- out[5] = a02 * a10 - a00 * a12;
6277
- out[6] = a10 * a21 - a11 * a20;
6278
- out[7] = a01 * a20 - a00 * a21;
6279
- out[8] = a00 * a11 - a01 * a10;
6396
+ function exp(out, a) {
6397
+ var x = a[0],
6398
+ y = a[1],
6399
+ z = a[2],
6400
+ w = a[3];
6401
+ var r = Math.sqrt(x * x + y * y + z * z);
6402
+ var et = Math.exp(w);
6403
+ var s = r > 0 ? et * Math.sin(r) / r : 0;
6404
+ out[0] = x * s;
6405
+ out[1] = y * s;
6406
+ out[2] = z * s;
6407
+ out[3] = et * Math.cos(r);
6280
6408
  return out;
6281
6409
  }
6282
6410
  /**
6283
- * Calculates the determinant of a mat3
6411
+ * Calculate the natural logarithm of a unit quaternion.
6284
6412
  *
6285
- * @param {ReadonlyMat3} a the source matrix
6286
- * @returns {Number} determinant of a
6413
+ * @param {quat} out the receiving quaternion
6414
+ * @param {ReadonlyQuat} a quat to calculate the exponential of
6415
+ * @returns {quat} out
6287
6416
  */
6288
6417
 
6289
- function determinant(a) {
6290
- var a00 = a[0],
6291
- a01 = a[1],
6292
- a02 = a[2];
6293
- var a10 = a[3],
6294
- a11 = a[4],
6295
- a12 = a[5];
6296
- var a20 = a[6],
6297
- a21 = a[7],
6298
- a22 = a[8];
6299
- return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
6418
+ function ln(out, a) {
6419
+ var x = a[0],
6420
+ y = a[1],
6421
+ z = a[2],
6422
+ w = a[3];
6423
+ var r = Math.sqrt(x * x + y * y + z * z);
6424
+ var t = r > 0 ? Math.atan2(r, w) / r : 0;
6425
+ out[0] = x * t;
6426
+ out[1] = y * t;
6427
+ out[2] = z * t;
6428
+ out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w);
6429
+ return out;
6300
6430
  }
6301
6431
  /**
6302
- * Multiplies two mat3's
6432
+ * Calculate the scalar power of a unit quaternion.
6303
6433
  *
6304
- * @param {mat3} out the receiving matrix
6305
- * @param {ReadonlyMat3} a the first operand
6306
- * @param {ReadonlyMat3} b the second operand
6307
- * @returns {mat3} out
6434
+ * @param {quat} out the receiving quaternion
6435
+ * @param {ReadonlyQuat} a quat to calculate the exponential of
6436
+ * @param {Number} b amount to scale the quaternion by
6437
+ * @returns {quat} out
6308
6438
  */
6309
6439
 
6310
- function multiply(out, a, b) {
6311
- var a00 = a[0],
6312
- a01 = a[1],
6313
- a02 = a[2];
6314
- var a10 = a[3],
6315
- a11 = a[4],
6316
- a12 = a[5];
6317
- var a20 = a[6],
6318
- a21 = a[7],
6319
- a22 = a[8];
6320
- var b00 = b[0],
6321
- b01 = b[1],
6322
- b02 = b[2];
6323
- var b10 = b[3],
6324
- b11 = b[4],
6325
- b12 = b[5];
6326
- var b20 = b[6],
6327
- b21 = b[7],
6328
- b22 = b[8];
6329
- out[0] = b00 * a00 + b01 * a10 + b02 * a20;
6330
- out[1] = b00 * a01 + b01 * a11 + b02 * a21;
6331
- out[2] = b00 * a02 + b01 * a12 + b02 * a22;
6332
- out[3] = b10 * a00 + b11 * a10 + b12 * a20;
6333
- out[4] = b10 * a01 + b11 * a11 + b12 * a21;
6334
- out[5] = b10 * a02 + b11 * a12 + b12 * a22;
6335
- out[6] = b20 * a00 + b21 * a10 + b22 * a20;
6336
- out[7] = b20 * a01 + b21 * a11 + b22 * a21;
6337
- out[8] = b20 * a02 + b21 * a12 + b22 * a22;
6440
+ function pow(out, a, b) {
6441
+ ln(out, a);
6442
+ scale(out, out, b);
6443
+ exp(out, out);
6338
6444
  return out;
6339
6445
  }
6340
6446
  /**
6341
- * Translate a mat3 by the given vector
6447
+ * Performs a spherical linear interpolation between two quat
6342
6448
  *
6343
- * @param {mat3} out the receiving matrix
6344
- * @param {ReadonlyMat3} a the matrix to translate
6345
- * @param {ReadonlyVec2} v vector to translate by
6346
- * @returns {mat3} out
6449
+ * @param {quat} out the receiving quaternion
6450
+ * @param {ReadonlyQuat} a the first operand
6451
+ * @param {ReadonlyQuat} b the second operand
6452
+ * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
6453
+ * @returns {quat} out
6347
6454
  */
6348
6455
 
6349
- function translate(out, a, v) {
6350
- var a00 = a[0],
6351
- a01 = a[1],
6352
- a02 = a[2],
6353
- a10 = a[3],
6354
- a11 = a[4],
6355
- a12 = a[5],
6356
- a20 = a[6],
6357
- a21 = a[7],
6358
- a22 = a[8],
6359
- x = v[0],
6360
- y = v[1];
6361
- out[0] = a00;
6362
- out[1] = a01;
6363
- out[2] = a02;
6364
- out[3] = a10;
6365
- out[4] = a11;
6366
- out[5] = a12;
6367
- out[6] = x * a00 + y * a10 + a20;
6368
- out[7] = x * a01 + y * a11 + a21;
6369
- out[8] = x * a02 + y * a12 + a22;
6370
- return out;
6371
- }
6372
- /**
6373
- * Rotates a mat3 by the given angle
6374
- *
6375
- * @param {mat3} out the receiving matrix
6376
- * @param {ReadonlyMat3} a the matrix to rotate
6377
- * @param {Number} rad the angle to rotate the matrix by
6378
- * @returns {mat3} out
6379
- */
6456
+ function slerp(out, a, b, t) {
6457
+ // benchmarks:
6458
+ // http://jsperf.com/quaternion-slerp-implementations
6459
+ var ax = a[0],
6460
+ ay = a[1],
6461
+ az = a[2],
6462
+ aw = a[3];
6463
+ var bx = b[0],
6464
+ by = b[1],
6465
+ bz = b[2],
6466
+ bw = b[3];
6467
+ var omega, cosom, sinom, scale0, scale1; // calc cosine
6380
6468
 
6381
- function rotate(out, a, rad) {
6382
- var a00 = a[0],
6383
- a01 = a[1],
6384
- a02 = a[2],
6385
- a10 = a[3],
6386
- a11 = a[4],
6387
- a12 = a[5],
6388
- a20 = a[6],
6389
- a21 = a[7],
6390
- a22 = a[8],
6391
- s = Math.sin(rad),
6392
- c = Math.cos(rad);
6393
- out[0] = c * a00 + s * a10;
6394
- out[1] = c * a01 + s * a11;
6395
- out[2] = c * a02 + s * a12;
6396
- out[3] = c * a10 - s * a00;
6397
- out[4] = c * a11 - s * a01;
6398
- out[5] = c * a12 - s * a02;
6399
- out[6] = a20;
6400
- out[7] = a21;
6401
- out[8] = a22;
6469
+ cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)
6470
+
6471
+ if (cosom < 0.0) {
6472
+ cosom = -cosom;
6473
+ bx = -bx;
6474
+ by = -by;
6475
+ bz = -bz;
6476
+ bw = -bw;
6477
+ } // calculate coefficients
6478
+
6479
+
6480
+ if (1.0 - cosom > _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON) {
6481
+ // standard case (slerp)
6482
+ omega = Math.acos(cosom);
6483
+ sinom = Math.sin(omega);
6484
+ scale0 = Math.sin((1.0 - t) * omega) / sinom;
6485
+ scale1 = Math.sin(t * omega) / sinom;
6486
+ } else {
6487
+ // "from" and "to" quaternions are very close
6488
+ // ... so we can do a linear interpolation
6489
+ scale0 = 1.0 - t;
6490
+ scale1 = t;
6491
+ } // calculate final values
6492
+
6493
+
6494
+ out[0] = scale0 * ax + scale1 * bx;
6495
+ out[1] = scale0 * ay + scale1 * by;
6496
+ out[2] = scale0 * az + scale1 * bz;
6497
+ out[3] = scale0 * aw + scale1 * bw;
6402
6498
  return out;
6403
6499
  }
6404
6500
  /**
6405
- * Scales the mat3 by the dimensions in the given vec2
6501
+ * Generates a random unit quaternion
6406
6502
  *
6407
- * @param {mat3} out the receiving matrix
6408
- * @param {ReadonlyMat3} a the matrix to rotate
6409
- * @param {ReadonlyVec2} v the vec2 to scale the matrix by
6410
- * @returns {mat3} out
6411
- **/
6503
+ * @param {quat} out the receiving quaternion
6504
+ * @returns {quat} out
6505
+ */
6412
6506
 
6413
- function scale(out, a, v) {
6414
- var x = v[0],
6415
- y = v[1];
6416
- out[0] = x * a[0];
6417
- out[1] = x * a[1];
6418
- out[2] = x * a[2];
6419
- out[3] = y * a[3];
6420
- out[4] = y * a[4];
6421
- out[5] = y * a[5];
6422
- out[6] = a[6];
6423
- out[7] = a[7];
6424
- out[8] = a[8];
6507
+ function random(out) {
6508
+ // Implementation of http://planning.cs.uiuc.edu/node198.html
6509
+ // TODO: Calling random 3 times is probably not the fastest solution
6510
+ var u1 = glMatrix.RANDOM();
6511
+ var u2 = glMatrix.RANDOM();
6512
+ var u3 = glMatrix.RANDOM();
6513
+ var sqrt1MinusU1 = Math.sqrt(1 - u1);
6514
+ var sqrtU1 = Math.sqrt(u1);
6515
+ out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2);
6516
+ out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2);
6517
+ out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3);
6518
+ out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3);
6425
6519
  return out;
6426
6520
  }
6427
6521
  /**
6428
- * Creates a matrix from a vector translation
6429
- * This is equivalent to (but much faster than):
6430
- *
6431
- * mat3.identity(dest);
6432
- * mat3.translate(dest, dest, vec);
6522
+ * Calculates the inverse of a quat
6433
6523
  *
6434
- * @param {mat3} out mat3 receiving operation result
6435
- * @param {ReadonlyVec2} v Translation vector
6436
- * @returns {mat3} out
6524
+ * @param {quat} out the receiving quaternion
6525
+ * @param {ReadonlyQuat} a quat to calculate inverse of
6526
+ * @returns {quat} out
6437
6527
  */
6438
6528
 
6439
- function fromTranslation(out, v) {
6440
- out[0] = 1;
6441
- out[1] = 0;
6442
- out[2] = 0;
6443
- out[3] = 0;
6444
- out[4] = 1;
6445
- out[5] = 0;
6446
- out[6] = v[0];
6447
- out[7] = v[1];
6448
- out[8] = 1;
6529
+ function invert(out, a) {
6530
+ var a0 = a[0],
6531
+ a1 = a[1],
6532
+ a2 = a[2],
6533
+ a3 = a[3];
6534
+ var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;
6535
+ var invDot = dot ? 1.0 / dot : 0; // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0
6536
+
6537
+ out[0] = -a0 * invDot;
6538
+ out[1] = -a1 * invDot;
6539
+ out[2] = -a2 * invDot;
6540
+ out[3] = a3 * invDot;
6449
6541
  return out;
6450
6542
  }
6451
6543
  /**
6452
- * Creates a matrix from a given angle
6453
- * This is equivalent to (but much faster than):
6454
- *
6455
- * mat3.identity(dest);
6456
- * mat3.rotate(dest, dest, rad);
6544
+ * Calculates the conjugate of a quat
6545
+ * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
6457
6546
  *
6458
- * @param {mat3} out mat3 receiving operation result
6459
- * @param {Number} rad the angle to rotate the matrix by
6460
- * @returns {mat3} out
6547
+ * @param {quat} out the receiving quaternion
6548
+ * @param {ReadonlyQuat} a quat to calculate conjugate of
6549
+ * @returns {quat} out
6461
6550
  */
6462
6551
 
6463
- function fromRotation(out, rad) {
6464
- var s = Math.sin(rad),
6465
- c = Math.cos(rad);
6466
- out[0] = c;
6467
- out[1] = s;
6468
- out[2] = 0;
6469
- out[3] = -s;
6470
- out[4] = c;
6471
- out[5] = 0;
6472
- out[6] = 0;
6473
- out[7] = 0;
6474
- out[8] = 1;
6552
+ function conjugate(out, a) {
6553
+ out[0] = -a[0];
6554
+ out[1] = -a[1];
6555
+ out[2] = -a[2];
6556
+ out[3] = a[3];
6475
6557
  return out;
6476
6558
  }
6477
6559
  /**
6478
- * Creates a matrix from a vector scaling
6479
- * This is equivalent to (but much faster than):
6560
+ * Creates a quaternion from the given 3x3 rotation matrix.
6480
6561
  *
6481
- * mat3.identity(dest);
6482
- * mat3.scale(dest, dest, vec);
6562
+ * NOTE: The resultant quaternion is not normalized, so you should be sure
6563
+ * to renormalize the quaternion yourself where necessary.
6483
6564
  *
6484
- * @param {mat3} out mat3 receiving operation result
6485
- * @param {ReadonlyVec2} v Scaling vector
6486
- * @returns {mat3} out
6565
+ * @param {quat} out the receiving quaternion
6566
+ * @param {ReadonlyMat3} m rotation matrix
6567
+ * @returns {quat} out
6568
+ * @function
6487
6569
  */
6488
6570
 
6489
- function fromScaling(out, v) {
6490
- out[0] = v[0];
6491
- out[1] = 0;
6492
- out[2] = 0;
6493
- out[3] = 0;
6494
- out[4] = v[1];
6495
- out[5] = 0;
6496
- out[6] = 0;
6497
- out[7] = 0;
6498
- out[8] = 1;
6499
- return out;
6500
- }
6501
- /**
6502
- * Copies the values from a mat2d into a mat3
6503
- *
6504
- * @param {mat3} out the receiving matrix
6505
- * @param {ReadonlyMat2d} a the matrix to copy
6506
- * @returns {mat3} out
6507
- **/
6571
+ function fromMat3(out, m) {
6572
+ // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
6573
+ // article "Quaternion Calculus and Fast Animation".
6574
+ var fTrace = m[0] + m[4] + m[8];
6575
+ var fRoot;
6576
+
6577
+ if (fTrace > 0.0) {
6578
+ // |w| > 1/2, may as well choose w > 1/2
6579
+ fRoot = Math.sqrt(fTrace + 1.0); // 2w
6580
+
6581
+ out[3] = 0.5 * fRoot;
6582
+ fRoot = 0.5 / fRoot; // 1/(4w)
6583
+
6584
+ out[0] = (m[5] - m[7]) * fRoot;
6585
+ out[1] = (m[6] - m[2]) * fRoot;
6586
+ out[2] = (m[1] - m[3]) * fRoot;
6587
+ } else {
6588
+ // |w| <= 1/2
6589
+ var i = 0;
6590
+ if (m[4] > m[0]) i = 1;
6591
+ if (m[8] > m[i * 3 + i]) i = 2;
6592
+ var j = (i + 1) % 3;
6593
+ var k = (i + 2) % 3;
6594
+ fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
6595
+ out[i] = 0.5 * fRoot;
6596
+ fRoot = 0.5 / fRoot;
6597
+ out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
6598
+ out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
6599
+ out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
6600
+ }
6508
6601
 
6509
- function fromMat2d(out, a) {
6510
- out[0] = a[0];
6511
- out[1] = a[1];
6512
- out[2] = 0;
6513
- out[3] = a[2];
6514
- out[4] = a[3];
6515
- out[5] = 0;
6516
- out[6] = a[4];
6517
- out[7] = a[5];
6518
- out[8] = 1;
6519
6602
  return out;
6520
6603
  }
6521
6604
  /**
6522
- * Calculates a 3x3 matrix from the given quaternion
6523
- *
6524
- * @param {mat3} out mat3 receiving operation result
6525
- * @param {ReadonlyQuat} q Quaternion to create matrix from
6605
+ * Creates a quaternion from the given euler angle x, y, z.
6526
6606
  *
6527
- * @returns {mat3} out
6607
+ * @param {quat} out the receiving quaternion
6608
+ * @param {x} Angle to rotate around X axis in degrees.
6609
+ * @param {y} Angle to rotate around Y axis in degrees.
6610
+ * @param {z} Angle to rotate around Z axis in degrees.
6611
+ * @returns {quat} out
6612
+ * @function
6528
6613
  */
6529
6614
 
6530
- function fromQuat(out, q) {
6531
- var x = q[0],
6532
- y = q[1],
6533
- z = q[2],
6534
- w = q[3];
6535
- var x2 = x + x;
6536
- var y2 = y + y;
6537
- var z2 = z + z;
6538
- var xx = x * x2;
6539
- var yx = y * x2;
6540
- var yy = y * y2;
6541
- var zx = z * x2;
6542
- var zy = z * y2;
6543
- var zz = z * z2;
6544
- var wx = w * x2;
6545
- var wy = w * y2;
6546
- var wz = w * z2;
6547
- out[0] = 1 - yy - zz;
6548
- out[3] = yx - wz;
6549
- out[6] = zx + wy;
6550
- out[1] = yx + wz;
6551
- out[4] = 1 - xx - zz;
6552
- out[7] = zy - wx;
6553
- out[2] = zx - wy;
6554
- out[5] = zy + wx;
6555
- out[8] = 1 - xx - yy;
6615
+ function fromEuler(out, x, y, z) {
6616
+ var halfToRad = 0.5 * Math.PI / 180.0;
6617
+ x *= halfToRad;
6618
+ y *= halfToRad;
6619
+ z *= halfToRad;
6620
+ var sx = Math.sin(x);
6621
+ var cx = Math.cos(x);
6622
+ var sy = Math.sin(y);
6623
+ var cy = Math.cos(y);
6624
+ var sz = Math.sin(z);
6625
+ var cz = Math.cos(z);
6626
+ out[0] = sx * cy * cz - cx * sy * sz;
6627
+ out[1] = cx * sy * cz + sx * cy * sz;
6628
+ out[2] = cx * cy * sz - sx * sy * cz;
6629
+ out[3] = cx * cy * cz + sx * sy * sz;
6556
6630
  return out;
6557
6631
  }
6558
6632
  /**
6559
- * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
6633
+ * Returns a string representation of a quatenion
6560
6634
  *
6561
- * @param {mat3} out mat3 receiving operation result
6562
- * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from
6635
+ * @param {ReadonlyQuat} a vector to represent as a string
6636
+ * @returns {String} string representation of the vector
6637
+ */
6638
+
6639
+ function str(a) {
6640
+ return "quat(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")";
6641
+ }
6642
+ /**
6643
+ * Creates a new quat initialized with values from an existing quaternion
6563
6644
  *
6564
- * @returns {mat3} out
6645
+ * @param {ReadonlyQuat} a quaternion to clone
6646
+ * @returns {quat} a new quaternion
6647
+ * @function
6565
6648
  */
6566
6649
 
6567
- function normalFromMat4(out, a) {
6568
- var a00 = a[0],
6569
- a01 = a[1],
6570
- a02 = a[2],
6571
- a03 = a[3];
6572
- var a10 = a[4],
6573
- a11 = a[5],
6574
- a12 = a[6],
6575
- a13 = a[7];
6576
- var a20 = a[8],
6577
- a21 = a[9],
6578
- a22 = a[10],
6579
- a23 = a[11];
6580
- var a30 = a[12],
6581
- a31 = a[13],
6582
- a32 = a[14],
6583
- a33 = a[15];
6584
- var b00 = a00 * a11 - a01 * a10;
6585
- var b01 = a00 * a12 - a02 * a10;
6586
- var b02 = a00 * a13 - a03 * a10;
6587
- var b03 = a01 * a12 - a02 * a11;
6588
- var b04 = a01 * a13 - a03 * a11;
6589
- var b05 = a02 * a13 - a03 * a12;
6590
- var b06 = a20 * a31 - a21 * a30;
6591
- var b07 = a20 * a32 - a22 * a30;
6592
- var b08 = a20 * a33 - a23 * a30;
6593
- var b09 = a21 * a32 - a22 * a31;
6594
- var b10 = a21 * a33 - a23 * a31;
6595
- var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
6650
+ var clone = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.clone;
6651
+ /**
6652
+ * Creates a new quat initialized with the given values
6653
+ *
6654
+ * @param {Number} x X component
6655
+ * @param {Number} y Y component
6656
+ * @param {Number} z Z component
6657
+ * @param {Number} w W component
6658
+ * @returns {quat} a new quaternion
6659
+ * @function
6660
+ */
6596
6661
 
6597
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
6662
+ var fromValues = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.fromValues;
6663
+ /**
6664
+ * Copy the values from one quat to another
6665
+ *
6666
+ * @param {quat} out the receiving quaternion
6667
+ * @param {ReadonlyQuat} a the source quaternion
6668
+ * @returns {quat} out
6669
+ * @function
6670
+ */
6598
6671
 
6599
- if (!det) {
6600
- return null;
6672
+ var copy = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.copy;
6673
+ /**
6674
+ * Set the components of a quat to the given values
6675
+ *
6676
+ * @param {quat} out the receiving quaternion
6677
+ * @param {Number} x X component
6678
+ * @param {Number} y Y component
6679
+ * @param {Number} z Z component
6680
+ * @param {Number} w W component
6681
+ * @returns {quat} out
6682
+ * @function
6683
+ */
6684
+
6685
+ var set = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.set;
6686
+ /**
6687
+ * Adds two quat's
6688
+ *
6689
+ * @param {quat} out the receiving quaternion
6690
+ * @param {ReadonlyQuat} a the first operand
6691
+ * @param {ReadonlyQuat} b the second operand
6692
+ * @returns {quat} out
6693
+ * @function
6694
+ */
6695
+
6696
+ var add = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.add;
6697
+ /**
6698
+ * Alias for {@link quat.multiply}
6699
+ * @function
6700
+ */
6701
+
6702
+ var mul = (/* unused pure expression or super */ null && (multiply));
6703
+ /**
6704
+ * Scales a quat by a scalar number
6705
+ *
6706
+ * @param {quat} out the receiving vector
6707
+ * @param {ReadonlyQuat} a the vector to scale
6708
+ * @param {Number} b amount to scale the vector by
6709
+ * @returns {quat} out
6710
+ * @function
6711
+ */
6712
+
6713
+ var scale = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.scale;
6714
+ /**
6715
+ * Calculates the dot product of two quat's
6716
+ *
6717
+ * @param {ReadonlyQuat} a the first operand
6718
+ * @param {ReadonlyQuat} b the second operand
6719
+ * @returns {Number} dot product of a and b
6720
+ * @function
6721
+ */
6722
+
6723
+ var dot = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.dot;
6724
+ /**
6725
+ * Performs a linear interpolation between two quat's
6726
+ *
6727
+ * @param {quat} out the receiving quaternion
6728
+ * @param {ReadonlyQuat} a the first operand
6729
+ * @param {ReadonlyQuat} b the second operand
6730
+ * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
6731
+ * @returns {quat} out
6732
+ * @function
6733
+ */
6734
+
6735
+ var lerp = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.lerp;
6736
+ /**
6737
+ * Calculates the length of a quat
6738
+ *
6739
+ * @param {ReadonlyQuat} a vector to calculate length of
6740
+ * @returns {Number} length of a
6741
+ */
6742
+
6743
+ var length = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.length;
6744
+ /**
6745
+ * Alias for {@link quat.length}
6746
+ * @function
6747
+ */
6748
+
6749
+ var len = (/* unused pure expression or super */ null && (length));
6750
+ /**
6751
+ * Calculates the squared length of a quat
6752
+ *
6753
+ * @param {ReadonlyQuat} a vector to calculate squared length of
6754
+ * @returns {Number} squared length of a
6755
+ * @function
6756
+ */
6757
+
6758
+ var squaredLength = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.squaredLength;
6759
+ /**
6760
+ * Alias for {@link quat.squaredLength}
6761
+ * @function
6762
+ */
6763
+
6764
+ var sqrLen = (/* unused pure expression or super */ null && (squaredLength));
6765
+ /**
6766
+ * Normalize a quat
6767
+ *
6768
+ * @param {quat} out the receiving quaternion
6769
+ * @param {ReadonlyQuat} a quaternion to normalize
6770
+ * @returns {quat} out
6771
+ * @function
6772
+ */
6773
+
6774
+ var normalize = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.normalize;
6775
+ /**
6776
+ * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
6777
+ *
6778
+ * @param {ReadonlyQuat} a The first quaternion.
6779
+ * @param {ReadonlyQuat} b The second quaternion.
6780
+ * @returns {Boolean} True if the vectors are equal, false otherwise.
6781
+ */
6782
+
6783
+ var exactEquals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.exactEquals;
6784
+ /**
6785
+ * Returns whether or not the quaternions have approximately the same elements in the same position.
6786
+ *
6787
+ * @param {ReadonlyQuat} a The first vector.
6788
+ * @param {ReadonlyQuat} b The second vector.
6789
+ * @returns {Boolean} True if the vectors are equal, false otherwise.
6790
+ */
6791
+
6792
+ var equals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.equals;
6793
+ /**
6794
+ * Sets a quaternion to represent the shortest rotation from one
6795
+ * vector to another.
6796
+ *
6797
+ * Both vectors are assumed to be unit length.
6798
+ *
6799
+ * @param {quat} out the receiving quaternion.
6800
+ * @param {ReadonlyVec3} a the initial vector
6801
+ * @param {ReadonlyVec3} b the destination vector
6802
+ * @returns {quat} out
6803
+ */
6804
+
6805
+ var rotationTo = function () {
6806
+ var tmpvec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.create();
6807
+ var xUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.fromValues(1, 0, 0);
6808
+ var yUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.fromValues(0, 1, 0);
6809
+ return function (out, a, b) {
6810
+ var dot = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.dot(a, b);
6811
+
6812
+ if (dot < -0.999999) {
6813
+ _vec3_js__WEBPACK_IMPORTED_MODULE_2__.cross(tmpvec3, xUnitVec3, a);
6814
+ if (_vec3_js__WEBPACK_IMPORTED_MODULE_2__.len(tmpvec3) < 0.000001) _vec3_js__WEBPACK_IMPORTED_MODULE_2__.cross(tmpvec3, yUnitVec3, a);
6815
+ _vec3_js__WEBPACK_IMPORTED_MODULE_2__.normalize(tmpvec3, tmpvec3);
6816
+ setAxisAngle(out, tmpvec3, Math.PI);
6817
+ return out;
6818
+ } else if (dot > 0.999999) {
6819
+ out[0] = 0;
6820
+ out[1] = 0;
6821
+ out[2] = 0;
6822
+ out[3] = 1;
6823
+ return out;
6824
+ } else {
6825
+ _vec3_js__WEBPACK_IMPORTED_MODULE_2__.cross(tmpvec3, a, b);
6826
+ out[0] = tmpvec3[0];
6827
+ out[1] = tmpvec3[1];
6828
+ out[2] = tmpvec3[2];
6829
+ out[3] = 1 + dot;
6830
+ return normalize(out, out);
6831
+ }
6832
+ };
6833
+ }();
6834
+ /**
6835
+ * Performs a spherical linear interpolation with two control points
6836
+ *
6837
+ * @param {quat} out the receiving quaternion
6838
+ * @param {ReadonlyQuat} a the first operand
6839
+ * @param {ReadonlyQuat} b the second operand
6840
+ * @param {ReadonlyQuat} c the third operand
6841
+ * @param {ReadonlyQuat} d the fourth operand
6842
+ * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
6843
+ * @returns {quat} out
6844
+ */
6845
+
6846
+ var sqlerp = function () {
6847
+ var temp1 = create();
6848
+ var temp2 = create();
6849
+ return function (out, a, b, c, d, t) {
6850
+ slerp(temp1, a, d, t);
6851
+ slerp(temp2, b, c, t);
6852
+ slerp(out, temp1, temp2, 2 * t * (1 - t));
6853
+ return out;
6854
+ };
6855
+ }();
6856
+ /**
6857
+ * Sets the specified quaternion with values corresponding to the given
6858
+ * axes. Each axis is a vec3 and is expected to be unit length and
6859
+ * perpendicular to all other specified axes.
6860
+ *
6861
+ * @param {ReadonlyVec3} view the vector representing the viewing direction
6862
+ * @param {ReadonlyVec3} right the vector representing the local "right" direction
6863
+ * @param {ReadonlyVec3} up the vector representing the local "up" direction
6864
+ * @returns {quat} out
6865
+ */
6866
+
6867
+ var setAxes = function () {
6868
+ var matr = _mat3_js__WEBPACK_IMPORTED_MODULE_1__.create();
6869
+ return function (out, view, right, up) {
6870
+ matr[0] = right[0];
6871
+ matr[3] = right[1];
6872
+ matr[6] = right[2];
6873
+ matr[1] = up[0];
6874
+ matr[4] = up[1];
6875
+ matr[7] = up[2];
6876
+ matr[2] = -view[0];
6877
+ matr[5] = -view[1];
6878
+ matr[8] = -view[2];
6879
+ return normalize(out, fromMat3(out, matr));
6880
+ };
6881
+ }();
6882
+
6883
+ /***/ }),
6884
+
6885
+ /***/ 67872:
6886
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6887
+
6888
+ "use strict";
6889
+ /* unused harmony exports create, clone, fromValues, copy, set, add, subtract, multiply, divide, ceil, floor, min, max, round, scale, scaleAndAdd, distance, squaredDistance, length, squaredLength, negate, inverse, normalize, dot, cross, lerp, random, transformMat2, transformMat2d, transformMat3, transformMat4, rotate, angle, zero, str, exactEquals, equals, len, sub, mul, div, dist, sqrDist, sqrLen, forEach */
6890
+ /* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24457);
6891
+
6892
+ /**
6893
+ * 2 Dimensional Vector
6894
+ * @module vec2
6895
+ */
6896
+
6897
+ /**
6898
+ * Creates a new, empty vec2
6899
+ *
6900
+ * @returns {vec2} a new 2D vector
6901
+ */
6902
+
6903
+ function create() {
6904
+ var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(2);
6905
+
6906
+ if (_common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE != Float32Array) {
6907
+ out[0] = 0;
6908
+ out[1] = 0;
6601
6909
  }
6602
6910
 
6603
- det = 1.0 / det;
6604
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
6605
- out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
6606
- out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
6607
- out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
6608
- out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
6609
- out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
6610
- out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
6611
- out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
6612
- out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
6613
6911
  return out;
6614
6912
  }
6615
6913
  /**
6616
- * Generates a 2D projection matrix with the given bounds
6914
+ * Creates a new vec2 initialized with values from an existing vector
6617
6915
  *
6618
- * @param {mat3} out mat3 frustum matrix will be written into
6619
- * @param {number} width Width of your gl context
6620
- * @param {number} height Height of gl context
6621
- * @returns {mat3} out
6916
+ * @param {ReadonlyVec2} a vector to clone
6917
+ * @returns {vec2} a new 2D vector
6622
6918
  */
6623
6919
 
6624
- function projection(out, width, height) {
6625
- out[0] = 2 / width;
6626
- out[1] = 0;
6627
- out[2] = 0;
6628
- out[3] = 0;
6629
- out[4] = -2 / height;
6630
- out[5] = 0;
6631
- out[6] = -1;
6632
- out[7] = 1;
6633
- out[8] = 1;
6920
+ function clone(a) {
6921
+ var out = new glMatrix.ARRAY_TYPE(2);
6922
+ out[0] = a[0];
6923
+ out[1] = a[1];
6924
+ return out;
6925
+ }
6926
+ /**
6927
+ * Creates a new vec2 initialized with the given values
6928
+ *
6929
+ * @param {Number} x X component
6930
+ * @param {Number} y Y component
6931
+ * @returns {vec2} a new 2D vector
6932
+ */
6933
+
6934
+ function fromValues(x, y) {
6935
+ var out = new glMatrix.ARRAY_TYPE(2);
6936
+ out[0] = x;
6937
+ out[1] = y;
6634
6938
  return out;
6635
6939
  }
6636
6940
  /**
6637
- * Returns a string representation of a mat3
6941
+ * Copy the values from one vec2 to another
6638
6942
  *
6639
- * @param {ReadonlyMat3} a matrix to represent as a string
6640
- * @returns {String} string representation of the matrix
6943
+ * @param {vec2} out the receiving vector
6944
+ * @param {ReadonlyVec2} a the source vector
6945
+ * @returns {vec2} out
6641
6946
  */
6642
6947
 
6643
- function str(a) {
6644
- return "mat3(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ")";
6948
+ function copy(out, a) {
6949
+ out[0] = a[0];
6950
+ out[1] = a[1];
6951
+ return out;
6645
6952
  }
6646
6953
  /**
6647
- * Returns Frobenius norm of a mat3
6954
+ * Set the components of a vec2 to the given values
6648
6955
  *
6649
- * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of
6650
- * @returns {Number} Frobenius norm
6956
+ * @param {vec2} out the receiving vector
6957
+ * @param {Number} x X component
6958
+ * @param {Number} y Y component
6959
+ * @returns {vec2} out
6651
6960
  */
6652
6961
 
6653
- function frob(a) {
6654
- return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
6962
+ function set(out, x, y) {
6963
+ out[0] = x;
6964
+ out[1] = y;
6965
+ return out;
6655
6966
  }
6656
6967
  /**
6657
- * Adds two mat3's
6968
+ * Adds two vec2's
6658
6969
  *
6659
- * @param {mat3} out the receiving matrix
6660
- * @param {ReadonlyMat3} a the first operand
6661
- * @param {ReadonlyMat3} b the second operand
6662
- * @returns {mat3} out
6970
+ * @param {vec2} out the receiving vector
6971
+ * @param {ReadonlyVec2} a the first operand
6972
+ * @param {ReadonlyVec2} b the second operand
6973
+ * @returns {vec2} out
6663
6974
  */
6664
6975
 
6665
6976
  function add(out, a, b) {
6666
6977
  out[0] = a[0] + b[0];
6667
6978
  out[1] = a[1] + b[1];
6668
- out[2] = a[2] + b[2];
6669
- out[3] = a[3] + b[3];
6670
- out[4] = a[4] + b[4];
6671
- out[5] = a[5] + b[5];
6672
- out[6] = a[6] + b[6];
6673
- out[7] = a[7] + b[7];
6674
- out[8] = a[8] + b[8];
6675
6979
  return out;
6676
6980
  }
6677
6981
  /**
6678
- * Subtracts matrix b from matrix a
6982
+ * Subtracts vector b from vector a
6679
6983
  *
6680
- * @param {mat3} out the receiving matrix
6681
- * @param {ReadonlyMat3} a the first operand
6682
- * @param {ReadonlyMat3} b the second operand
6683
- * @returns {mat3} out
6984
+ * @param {vec2} out the receiving vector
6985
+ * @param {ReadonlyVec2} a the first operand
6986
+ * @param {ReadonlyVec2} b the second operand
6987
+ * @returns {vec2} out
6684
6988
  */
6685
6989
 
6686
6990
  function subtract(out, a, b) {
6687
6991
  out[0] = a[0] - b[0];
6688
6992
  out[1] = a[1] - b[1];
6689
- out[2] = a[2] - b[2];
6690
- out[3] = a[3] - b[3];
6691
- out[4] = a[4] - b[4];
6692
- out[5] = a[5] - b[5];
6693
- out[6] = a[6] - b[6];
6694
- out[7] = a[7] - b[7];
6695
- out[8] = a[8] - b[8];
6696
6993
  return out;
6697
6994
  }
6698
6995
  /**
6699
- * Multiply each element of the matrix by a scalar.
6996
+ * Multiplies two vec2's
6700
6997
  *
6701
- * @param {mat3} out the receiving matrix
6702
- * @param {ReadonlyMat3} a the matrix to scale
6703
- * @param {Number} b amount to scale the matrix's elements by
6704
- * @returns {mat3} out
6998
+ * @param {vec2} out the receiving vector
6999
+ * @param {ReadonlyVec2} a the first operand
7000
+ * @param {ReadonlyVec2} b the second operand
7001
+ * @returns {vec2} out
6705
7002
  */
6706
7003
 
6707
- function multiplyScalar(out, a, b) {
6708
- out[0] = a[0] * b;
6709
- out[1] = a[1] * b;
6710
- out[2] = a[2] * b;
6711
- out[3] = a[3] * b;
6712
- out[4] = a[4] * b;
6713
- out[5] = a[5] * b;
6714
- out[6] = a[6] * b;
6715
- out[7] = a[7] * b;
6716
- out[8] = a[8] * b;
7004
+ function multiply(out, a, b) {
7005
+ out[0] = a[0] * b[0];
7006
+ out[1] = a[1] * b[1];
6717
7007
  return out;
6718
7008
  }
6719
7009
  /**
6720
- * Adds two mat3's after multiplying each element of the second operand by a scalar value.
7010
+ * Divides two vec2's
6721
7011
  *
6722
- * @param {mat3} out the receiving vector
6723
- * @param {ReadonlyMat3} a the first operand
6724
- * @param {ReadonlyMat3} b the second operand
6725
- * @param {Number} scale the amount to scale b's elements by before adding
6726
- * @returns {mat3} out
7012
+ * @param {vec2} out the receiving vector
7013
+ * @param {ReadonlyVec2} a the first operand
7014
+ * @param {ReadonlyVec2} b the second operand
7015
+ * @returns {vec2} out
6727
7016
  */
6728
7017
 
6729
- function multiplyScalarAndAdd(out, a, b, scale) {
6730
- out[0] = a[0] + b[0] * scale;
6731
- out[1] = a[1] + b[1] * scale;
6732
- out[2] = a[2] + b[2] * scale;
6733
- out[3] = a[3] + b[3] * scale;
6734
- out[4] = a[4] + b[4] * scale;
6735
- out[5] = a[5] + b[5] * scale;
6736
- out[6] = a[6] + b[6] * scale;
6737
- out[7] = a[7] + b[7] * scale;
6738
- out[8] = a[8] + b[8] * scale;
7018
+ function divide(out, a, b) {
7019
+ out[0] = a[0] / b[0];
7020
+ out[1] = a[1] / b[1];
6739
7021
  return out;
6740
7022
  }
6741
7023
  /**
6742
- * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
7024
+ * Math.ceil the components of a vec2
6743
7025
  *
6744
- * @param {ReadonlyMat3} a The first matrix.
6745
- * @param {ReadonlyMat3} b The second matrix.
6746
- * @returns {Boolean} True if the matrices are equal, false otherwise.
7026
+ * @param {vec2} out the receiving vector
7027
+ * @param {ReadonlyVec2} a vector to ceil
7028
+ * @returns {vec2} out
6747
7029
  */
6748
7030
 
6749
- function exactEquals(a, b) {
6750
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
7031
+ function ceil(out, a) {
7032
+ out[0] = Math.ceil(a[0]);
7033
+ out[1] = Math.ceil(a[1]);
7034
+ return out;
6751
7035
  }
6752
7036
  /**
6753
- * Returns whether or not the matrices have approximately the same elements in the same position.
7037
+ * Math.floor the components of a vec2
6754
7038
  *
6755
- * @param {ReadonlyMat3} a The first matrix.
6756
- * @param {ReadonlyMat3} b The second matrix.
6757
- * @returns {Boolean} True if the matrices are equal, false otherwise.
7039
+ * @param {vec2} out the receiving vector
7040
+ * @param {ReadonlyVec2} a vector to floor
7041
+ * @returns {vec2} out
6758
7042
  */
6759
7043
 
6760
- function equals(a, b) {
6761
- var a0 = a[0],
6762
- a1 = a[1],
6763
- a2 = a[2],
6764
- a3 = a[3],
6765
- a4 = a[4],
6766
- a5 = a[5],
6767
- a6 = a[6],
6768
- a7 = a[7],
6769
- a8 = a[8];
6770
- var b0 = b[0],
6771
- b1 = b[1],
6772
- b2 = b[2],
6773
- b3 = b[3],
6774
- b4 = b[4],
6775
- b5 = b[5],
6776
- b6 = b[6],
6777
- b7 = b[7],
6778
- b8 = b[8];
6779
- return Math.abs(a0 - b0) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
7044
+ function floor(out, a) {
7045
+ out[0] = Math.floor(a[0]);
7046
+ out[1] = Math.floor(a[1]);
7047
+ return out;
6780
7048
  }
6781
7049
  /**
6782
- * Alias for {@link mat3.multiply}
6783
- * @function
6784
- */
6785
-
6786
- var mul = multiply;
6787
- /**
6788
- * Alias for {@link mat3.subtract}
6789
- * @function
7050
+ * Returns the minimum of two vec2's
7051
+ *
7052
+ * @param {vec2} out the receiving vector
7053
+ * @param {ReadonlyVec2} a the first operand
7054
+ * @param {ReadonlyVec2} b the second operand
7055
+ * @returns {vec2} out
6790
7056
  */
6791
7057
 
6792
- var sub = subtract;
6793
-
6794
- /***/ }),
6795
-
6796
- /***/ 50095:
6797
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6798
-
6799
- "use strict";
6800
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6801
- /* harmony export */ copy: () => (/* binding */ copy),
6802
- /* harmony export */ dot: () => (/* binding */ dot),
6803
- /* harmony export */ length: () => (/* binding */ length),
6804
- /* harmony export */ squaredLength: () => (/* binding */ squaredLength)
6805
- /* harmony export */ });
6806
- /* unused harmony exports create, identity, setAxisAngle, getAxisAngle, getAngle, multiply, rotateX, rotateY, rotateZ, calculateW, exp, ln, pow, slerp, random, invert, conjugate, fromMat3, fromEuler, str, clone, fromValues, set, add, mul, scale, lerp, len, sqrLen, normalize, exactEquals, equals, rotationTo, sqlerp, setAxes */
6807
- /* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24457);
6808
- /* harmony import */ var _mat3_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(32591);
6809
- /* harmony import */ var _vec3_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9175);
6810
- /* harmony import */ var _vec4_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15958);
6811
-
6812
-
6813
-
6814
-
7058
+ function min(out, a, b) {
7059
+ out[0] = Math.min(a[0], b[0]);
7060
+ out[1] = Math.min(a[1], b[1]);
7061
+ return out;
7062
+ }
6815
7063
  /**
6816
- * Quaternion
6817
- * @module quat
7064
+ * Returns the maximum of two vec2's
7065
+ *
7066
+ * @param {vec2} out the receiving vector
7067
+ * @param {ReadonlyVec2} a the first operand
7068
+ * @param {ReadonlyVec2} b the second operand
7069
+ * @returns {vec2} out
6818
7070
  */
6819
7071
 
7072
+ function max(out, a, b) {
7073
+ out[0] = Math.max(a[0], b[0]);
7074
+ out[1] = Math.max(a[1], b[1]);
7075
+ return out;
7076
+ }
6820
7077
  /**
6821
- * Creates a new identity quat
7078
+ * Math.round the components of a vec2
6822
7079
  *
6823
- * @returns {quat} a new quaternion
7080
+ * @param {vec2} out the receiving vector
7081
+ * @param {ReadonlyVec2} a vector to round
7082
+ * @returns {vec2} out
6824
7083
  */
6825
7084
 
6826
- function create() {
6827
- var out = new _common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE(4);
6828
-
6829
- if (_common_js__WEBPACK_IMPORTED_MODULE_0__.ARRAY_TYPE != Float32Array) {
6830
- out[0] = 0;
6831
- out[1] = 0;
6832
- out[2] = 0;
6833
- }
6834
-
6835
- out[3] = 1;
7085
+ function round(out, a) {
7086
+ out[0] = Math.round(a[0]);
7087
+ out[1] = Math.round(a[1]);
6836
7088
  return out;
6837
7089
  }
6838
7090
  /**
6839
- * Set a quat to the identity quaternion
7091
+ * Scales a vec2 by a scalar number
6840
7092
  *
6841
- * @param {quat} out the receiving quaternion
6842
- * @returns {quat} out
7093
+ * @param {vec2} out the receiving vector
7094
+ * @param {ReadonlyVec2} a the vector to scale
7095
+ * @param {Number} b amount to scale the vector by
7096
+ * @returns {vec2} out
6843
7097
  */
6844
7098
 
6845
- function identity(out) {
6846
- out[0] = 0;
6847
- out[1] = 0;
6848
- out[2] = 0;
6849
- out[3] = 1;
7099
+ function scale(out, a, b) {
7100
+ out[0] = a[0] * b;
7101
+ out[1] = a[1] * b;
6850
7102
  return out;
6851
7103
  }
6852
7104
  /**
6853
- * Sets a quat from the given angle and rotation axis,
6854
- * then returns it.
7105
+ * Adds two vec2's after scaling the second operand by a scalar value
6855
7106
  *
6856
- * @param {quat} out the receiving quaternion
6857
- * @param {ReadonlyVec3} axis the axis around which to rotate
6858
- * @param {Number} rad the angle in radians
6859
- * @returns {quat} out
6860
- **/
7107
+ * @param {vec2} out the receiving vector
7108
+ * @param {ReadonlyVec2} a the first operand
7109
+ * @param {ReadonlyVec2} b the second operand
7110
+ * @param {Number} scale the amount to scale b by before adding
7111
+ * @returns {vec2} out
7112
+ */
6861
7113
 
6862
- function setAxisAngle(out, axis, rad) {
6863
- rad = rad * 0.5;
6864
- var s = Math.sin(rad);
6865
- out[0] = s * axis[0];
6866
- out[1] = s * axis[1];
6867
- out[2] = s * axis[2];
6868
- out[3] = Math.cos(rad);
7114
+ function scaleAndAdd(out, a, b, scale) {
7115
+ out[0] = a[0] + b[0] * scale;
7116
+ out[1] = a[1] + b[1] * scale;
6869
7117
  return out;
6870
7118
  }
6871
7119
  /**
6872
- * Gets the rotation axis and angle for a given
6873
- * quaternion. If a quaternion is created with
6874
- * setAxisAngle, this method will return the same
6875
- * values as providied in the original parameter list
6876
- * OR functionally equivalent values.
6877
- * Example: The quaternion formed by axis [0, 0, 1] and
6878
- * angle -90 is the same as the quaternion formed by
6879
- * [0, 0, 1] and 270. This method favors the latter.
6880
- * @param {vec3} out_axis Vector receiving the axis of rotation
6881
- * @param {ReadonlyQuat} q Quaternion to be decomposed
6882
- * @return {Number} Angle, in radians, of the rotation
7120
+ * Calculates the euclidian distance between two vec2's
7121
+ *
7122
+ * @param {ReadonlyVec2} a the first operand
7123
+ * @param {ReadonlyVec2} b the second operand
7124
+ * @returns {Number} distance between a and b
6883
7125
  */
6884
7126
 
6885
- function getAxisAngle(out_axis, q) {
6886
- var rad = Math.acos(q[3]) * 2.0;
6887
- var s = Math.sin(rad / 2.0);
6888
-
6889
- if (s > glMatrix.EPSILON) {
6890
- out_axis[0] = q[0] / s;
6891
- out_axis[1] = q[1] / s;
6892
- out_axis[2] = q[2] / s;
6893
- } else {
6894
- // If s is zero, return any axis (no rotation - axis does not matter)
6895
- out_axis[0] = 1;
6896
- out_axis[1] = 0;
6897
- out_axis[2] = 0;
6898
- }
6899
-
6900
- return rad;
7127
+ function distance(a, b) {
7128
+ var x = b[0] - a[0],
7129
+ y = b[1] - a[1];
7130
+ return Math.hypot(x, y);
6901
7131
  }
6902
7132
  /**
6903
- * Gets the angular distance between two unit quaternions
7133
+ * Calculates the squared euclidian distance between two vec2's
6904
7134
  *
6905
- * @param {ReadonlyQuat} a Origin unit quaternion
6906
- * @param {ReadonlyQuat} b Destination unit quaternion
6907
- * @return {Number} Angle, in radians, between the two quaternions
7135
+ * @param {ReadonlyVec2} a the first operand
7136
+ * @param {ReadonlyVec2} b the second operand
7137
+ * @returns {Number} squared distance between a and b
6908
7138
  */
6909
7139
 
6910
- function getAngle(a, b) {
6911
- var dotproduct = dot(a, b);
6912
- return Math.acos(2 * dotproduct * dotproduct - 1);
7140
+ function squaredDistance(a, b) {
7141
+ var x = b[0] - a[0],
7142
+ y = b[1] - a[1];
7143
+ return x * x + y * y;
6913
7144
  }
6914
7145
  /**
6915
- * Multiplies two quat's
7146
+ * Calculates the length of a vec2
6916
7147
  *
6917
- * @param {quat} out the receiving quaternion
6918
- * @param {ReadonlyQuat} a the first operand
6919
- * @param {ReadonlyQuat} b the second operand
6920
- * @returns {quat} out
7148
+ * @param {ReadonlyVec2} a vector to calculate length of
7149
+ * @returns {Number} length of a
6921
7150
  */
6922
7151
 
6923
- function multiply(out, a, b) {
6924
- var ax = a[0],
6925
- ay = a[1],
6926
- az = a[2],
6927
- aw = a[3];
6928
- var bx = b[0],
6929
- by = b[1],
6930
- bz = b[2],
6931
- bw = b[3];
6932
- out[0] = ax * bw + aw * bx + ay * bz - az * by;
6933
- out[1] = ay * bw + aw * by + az * bx - ax * bz;
6934
- out[2] = az * bw + aw * bz + ax * by - ay * bx;
6935
- out[3] = aw * bw - ax * bx - ay * by - az * bz;
6936
- return out;
7152
+ function length(a) {
7153
+ var x = a[0],
7154
+ y = a[1];
7155
+ return Math.hypot(x, y);
6937
7156
  }
6938
7157
  /**
6939
- * Rotates a quaternion by the given angle about the X axis
7158
+ * Calculates the squared length of a vec2
6940
7159
  *
6941
- * @param {quat} out quat receiving operation result
6942
- * @param {ReadonlyQuat} a quat to rotate
6943
- * @param {number} rad angle (in radians) to rotate
6944
- * @returns {quat} out
7160
+ * @param {ReadonlyVec2} a vector to calculate squared length of
7161
+ * @returns {Number} squared length of a
6945
7162
  */
6946
7163
 
6947
- function rotateX(out, a, rad) {
6948
- rad *= 0.5;
6949
- var ax = a[0],
6950
- ay = a[1],
6951
- az = a[2],
6952
- aw = a[3];
6953
- var bx = Math.sin(rad),
6954
- bw = Math.cos(rad);
6955
- out[0] = ax * bw + aw * bx;
6956
- out[1] = ay * bw + az * bx;
6957
- out[2] = az * bw - ay * bx;
6958
- out[3] = aw * bw - ax * bx;
6959
- return out;
7164
+ function squaredLength(a) {
7165
+ var x = a[0],
7166
+ y = a[1];
7167
+ return x * x + y * y;
6960
7168
  }
6961
7169
  /**
6962
- * Rotates a quaternion by the given angle about the Y axis
7170
+ * Negates the components of a vec2
6963
7171
  *
6964
- * @param {quat} out quat receiving operation result
6965
- * @param {ReadonlyQuat} a quat to rotate
6966
- * @param {number} rad angle (in radians) to rotate
6967
- * @returns {quat} out
7172
+ * @param {vec2} out the receiving vector
7173
+ * @param {ReadonlyVec2} a vector to negate
7174
+ * @returns {vec2} out
6968
7175
  */
6969
7176
 
6970
- function rotateY(out, a, rad) {
6971
- rad *= 0.5;
6972
- var ax = a[0],
6973
- ay = a[1],
6974
- az = a[2],
6975
- aw = a[3];
6976
- var by = Math.sin(rad),
6977
- bw = Math.cos(rad);
6978
- out[0] = ax * bw - az * by;
6979
- out[1] = ay * bw + aw * by;
6980
- out[2] = az * bw + ax * by;
6981
- out[3] = aw * bw - ay * by;
7177
+ function negate(out, a) {
7178
+ out[0] = -a[0];
7179
+ out[1] = -a[1];
6982
7180
  return out;
6983
7181
  }
6984
7182
  /**
6985
- * Rotates a quaternion by the given angle about the Z axis
7183
+ * Returns the inverse of the components of a vec2
6986
7184
  *
6987
- * @param {quat} out quat receiving operation result
6988
- * @param {ReadonlyQuat} a quat to rotate
6989
- * @param {number} rad angle (in radians) to rotate
6990
- * @returns {quat} out
7185
+ * @param {vec2} out the receiving vector
7186
+ * @param {ReadonlyVec2} a vector to invert
7187
+ * @returns {vec2} out
6991
7188
  */
6992
7189
 
6993
- function rotateZ(out, a, rad) {
6994
- rad *= 0.5;
6995
- var ax = a[0],
6996
- ay = a[1],
6997
- az = a[2],
6998
- aw = a[3];
6999
- var bz = Math.sin(rad),
7000
- bw = Math.cos(rad);
7001
- out[0] = ax * bw + ay * bz;
7002
- out[1] = ay * bw - ax * bz;
7003
- out[2] = az * bw + aw * bz;
7004
- out[3] = aw * bw - az * bz;
7190
+ function inverse(out, a) {
7191
+ out[0] = 1.0 / a[0];
7192
+ out[1] = 1.0 / a[1];
7005
7193
  return out;
7006
7194
  }
7007
7195
  /**
7008
- * Calculates the W component of a quat from the X, Y, and Z components.
7009
- * Assumes that quaternion is 1 unit in length.
7010
- * Any existing W component will be ignored.
7196
+ * Normalize a vec2
7011
7197
  *
7012
- * @param {quat} out the receiving quaternion
7013
- * @param {ReadonlyQuat} a quat to calculate W component of
7014
- * @returns {quat} out
7198
+ * @param {vec2} out the receiving vector
7199
+ * @param {ReadonlyVec2} a vector to normalize
7200
+ * @returns {vec2} out
7015
7201
  */
7016
7202
 
7017
- function calculateW(out, a) {
7203
+ function normalize(out, a) {
7018
7204
  var x = a[0],
7019
- y = a[1],
7020
- z = a[2];
7021
- out[0] = x;
7022
- out[1] = y;
7023
- out[2] = z;
7024
- out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));
7205
+ y = a[1];
7206
+ var len = x * x + y * y;
7207
+
7208
+ if (len > 0) {
7209
+ //TODO: evaluate use of glm_invsqrt here?
7210
+ len = 1 / Math.sqrt(len);
7211
+ }
7212
+
7213
+ out[0] = a[0] * len;
7214
+ out[1] = a[1] * len;
7025
7215
  return out;
7026
7216
  }
7027
7217
  /**
7028
- * Calculate the exponential of a unit quaternion.
7218
+ * Calculates the dot product of two vec2's
7029
7219
  *
7030
- * @param {quat} out the receiving quaternion
7031
- * @param {ReadonlyQuat} a quat to calculate the exponential of
7032
- * @returns {quat} out
7220
+ * @param {ReadonlyVec2} a the first operand
7221
+ * @param {ReadonlyVec2} b the second operand
7222
+ * @returns {Number} dot product of a and b
7033
7223
  */
7034
7224
 
7035
- function exp(out, a) {
7036
- var x = a[0],
7037
- y = a[1],
7038
- z = a[2],
7039
- w = a[3];
7040
- var r = Math.sqrt(x * x + y * y + z * z);
7041
- var et = Math.exp(w);
7042
- var s = r > 0 ? et * Math.sin(r) / r : 0;
7043
- out[0] = x * s;
7044
- out[1] = y * s;
7045
- out[2] = z * s;
7046
- out[3] = et * Math.cos(r);
7047
- return out;
7225
+ function dot(a, b) {
7226
+ return a[0] * b[0] + a[1] * b[1];
7048
7227
  }
7049
7228
  /**
7050
- * Calculate the natural logarithm of a unit quaternion.
7229
+ * Computes the cross product of two vec2's
7230
+ * Note that the cross product must by definition produce a 3D vector
7051
7231
  *
7052
- * @param {quat} out the receiving quaternion
7053
- * @param {ReadonlyQuat} a quat to calculate the exponential of
7054
- * @returns {quat} out
7232
+ * @param {vec3} out the receiving vector
7233
+ * @param {ReadonlyVec2} a the first operand
7234
+ * @param {ReadonlyVec2} b the second operand
7235
+ * @returns {vec3} out
7055
7236
  */
7056
7237
 
7057
- function ln(out, a) {
7058
- var x = a[0],
7059
- y = a[1],
7060
- z = a[2],
7061
- w = a[3];
7062
- var r = Math.sqrt(x * x + y * y + z * z);
7063
- var t = r > 0 ? Math.atan2(r, w) / r : 0;
7064
- out[0] = x * t;
7065
- out[1] = y * t;
7066
- out[2] = z * t;
7067
- out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w);
7238
+ function cross(out, a, b) {
7239
+ var z = a[0] * b[1] - a[1] * b[0];
7240
+ out[0] = out[1] = 0;
7241
+ out[2] = z;
7242
+ return out;
7243
+ }
7244
+ /**
7245
+ * Performs a linear interpolation between two vec2's
7246
+ *
7247
+ * @param {vec2} out the receiving vector
7248
+ * @param {ReadonlyVec2} a the first operand
7249
+ * @param {ReadonlyVec2} b the second operand
7250
+ * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
7251
+ * @returns {vec2} out
7252
+ */
7253
+
7254
+ function lerp(out, a, b, t) {
7255
+ var ax = a[0],
7256
+ ay = a[1];
7257
+ out[0] = ax + t * (b[0] - ax);
7258
+ out[1] = ay + t * (b[1] - ay);
7068
7259
  return out;
7069
7260
  }
7070
7261
  /**
7071
- * Calculate the scalar power of a unit quaternion.
7262
+ * Generates a random vector with the given scale
7072
7263
  *
7073
- * @param {quat} out the receiving quaternion
7074
- * @param {ReadonlyQuat} a quat to calculate the exponential of
7075
- * @param {Number} b amount to scale the quaternion by
7076
- * @returns {quat} out
7264
+ * @param {vec2} out the receiving vector
7265
+ * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
7266
+ * @returns {vec2} out
7077
7267
  */
7078
7268
 
7079
- function pow(out, a, b) {
7080
- ln(out, a);
7081
- scale(out, out, b);
7082
- exp(out, out);
7269
+ function random(out, scale) {
7270
+ scale = scale || 1.0;
7271
+ var r = glMatrix.RANDOM() * 2.0 * Math.PI;
7272
+ out[0] = Math.cos(r) * scale;
7273
+ out[1] = Math.sin(r) * scale;
7083
7274
  return out;
7084
7275
  }
7085
7276
  /**
7086
- * Performs a spherical linear interpolation between two quat
7277
+ * Transforms the vec2 with a mat2
7087
7278
  *
7088
- * @param {quat} out the receiving quaternion
7089
- * @param {ReadonlyQuat} a the first operand
7090
- * @param {ReadonlyQuat} b the second operand
7091
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
7092
- * @returns {quat} out
7279
+ * @param {vec2} out the receiving vector
7280
+ * @param {ReadonlyVec2} a the vector to transform
7281
+ * @param {ReadonlyMat2} m matrix to transform with
7282
+ * @returns {vec2} out
7093
7283
  */
7094
7284
 
7095
- function slerp(out, a, b, t) {
7096
- // benchmarks:
7097
- // http://jsperf.com/quaternion-slerp-implementations
7098
- var ax = a[0],
7099
- ay = a[1],
7100
- az = a[2],
7101
- aw = a[3];
7102
- var bx = b[0],
7103
- by = b[1],
7104
- bz = b[2],
7105
- bw = b[3];
7106
- var omega, cosom, sinom, scale0, scale1; // calc cosine
7107
-
7108
- cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)
7109
-
7110
- if (cosom < 0.0) {
7111
- cosom = -cosom;
7112
- bx = -bx;
7113
- by = -by;
7114
- bz = -bz;
7115
- bw = -bw;
7116
- } // calculate coefficients
7117
-
7118
-
7119
- if (1.0 - cosom > _common_js__WEBPACK_IMPORTED_MODULE_0__.EPSILON) {
7120
- // standard case (slerp)
7121
- omega = Math.acos(cosom);
7122
- sinom = Math.sin(omega);
7123
- scale0 = Math.sin((1.0 - t) * omega) / sinom;
7124
- scale1 = Math.sin(t * omega) / sinom;
7125
- } else {
7126
- // "from" and "to" quaternions are very close
7127
- // ... so we can do a linear interpolation
7128
- scale0 = 1.0 - t;
7129
- scale1 = t;
7130
- } // calculate final values
7131
-
7132
-
7133
- out[0] = scale0 * ax + scale1 * bx;
7134
- out[1] = scale0 * ay + scale1 * by;
7135
- out[2] = scale0 * az + scale1 * bz;
7136
- out[3] = scale0 * aw + scale1 * bw;
7285
+ function transformMat2(out, a, m) {
7286
+ var x = a[0],
7287
+ y = a[1];
7288
+ out[0] = m[0] * x + m[2] * y;
7289
+ out[1] = m[1] * x + m[3] * y;
7137
7290
  return out;
7138
7291
  }
7139
7292
  /**
7140
- * Generates a random unit quaternion
7293
+ * Transforms the vec2 with a mat2d
7141
7294
  *
7142
- * @param {quat} out the receiving quaternion
7143
- * @returns {quat} out
7295
+ * @param {vec2} out the receiving vector
7296
+ * @param {ReadonlyVec2} a the vector to transform
7297
+ * @param {ReadonlyMat2d} m matrix to transform with
7298
+ * @returns {vec2} out
7144
7299
  */
7145
7300
 
7146
- function random(out) {
7147
- // Implementation of http://planning.cs.uiuc.edu/node198.html
7148
- // TODO: Calling random 3 times is probably not the fastest solution
7149
- var u1 = glMatrix.RANDOM();
7150
- var u2 = glMatrix.RANDOM();
7151
- var u3 = glMatrix.RANDOM();
7152
- var sqrt1MinusU1 = Math.sqrt(1 - u1);
7153
- var sqrtU1 = Math.sqrt(u1);
7154
- out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2);
7155
- out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2);
7156
- out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3);
7157
- out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3);
7301
+ function transformMat2d(out, a, m) {
7302
+ var x = a[0],
7303
+ y = a[1];
7304
+ out[0] = m[0] * x + m[2] * y + m[4];
7305
+ out[1] = m[1] * x + m[3] * y + m[5];
7158
7306
  return out;
7159
7307
  }
7160
7308
  /**
7161
- * Calculates the inverse of a quat
7309
+ * Transforms the vec2 with a mat3
7310
+ * 3rd vector component is implicitly '1'
7162
7311
  *
7163
- * @param {quat} out the receiving quaternion
7164
- * @param {ReadonlyQuat} a quat to calculate inverse of
7165
- * @returns {quat} out
7312
+ * @param {vec2} out the receiving vector
7313
+ * @param {ReadonlyVec2} a the vector to transform
7314
+ * @param {ReadonlyMat3} m matrix to transform with
7315
+ * @returns {vec2} out
7166
7316
  */
7167
7317
 
7168
- function invert(out, a) {
7169
- var a0 = a[0],
7170
- a1 = a[1],
7171
- a2 = a[2],
7172
- a3 = a[3];
7173
- var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;
7174
- var invDot = dot ? 1.0 / dot : 0; // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0
7175
-
7176
- out[0] = -a0 * invDot;
7177
- out[1] = -a1 * invDot;
7178
- out[2] = -a2 * invDot;
7179
- out[3] = a3 * invDot;
7318
+ function transformMat3(out, a, m) {
7319
+ var x = a[0],
7320
+ y = a[1];
7321
+ out[0] = m[0] * x + m[3] * y + m[6];
7322
+ out[1] = m[1] * x + m[4] * y + m[7];
7180
7323
  return out;
7181
7324
  }
7182
7325
  /**
7183
- * Calculates the conjugate of a quat
7184
- * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
7326
+ * Transforms the vec2 with a mat4
7327
+ * 3rd vector component is implicitly '0'
7328
+ * 4th vector component is implicitly '1'
7185
7329
  *
7186
- * @param {quat} out the receiving quaternion
7187
- * @param {ReadonlyQuat} a quat to calculate conjugate of
7188
- * @returns {quat} out
7330
+ * @param {vec2} out the receiving vector
7331
+ * @param {ReadonlyVec2} a the vector to transform
7332
+ * @param {ReadonlyMat4} m matrix to transform with
7333
+ * @returns {vec2} out
7189
7334
  */
7190
7335
 
7191
- function conjugate(out, a) {
7192
- out[0] = -a[0];
7193
- out[1] = -a[1];
7194
- out[2] = -a[2];
7195
- out[3] = a[3];
7336
+ function transformMat4(out, a, m) {
7337
+ var x = a[0];
7338
+ var y = a[1];
7339
+ out[0] = m[0] * x + m[4] * y + m[12];
7340
+ out[1] = m[1] * x + m[5] * y + m[13];
7196
7341
  return out;
7197
7342
  }
7198
7343
  /**
7199
- * Creates a quaternion from the given 3x3 rotation matrix.
7200
- *
7201
- * NOTE: The resultant quaternion is not normalized, so you should be sure
7202
- * to renormalize the quaternion yourself where necessary.
7203
- *
7204
- * @param {quat} out the receiving quaternion
7205
- * @param {ReadonlyMat3} m rotation matrix
7206
- * @returns {quat} out
7207
- * @function
7344
+ * Rotate a 2D vector
7345
+ * @param {vec2} out The receiving vec2
7346
+ * @param {ReadonlyVec2} a The vec2 point to rotate
7347
+ * @param {ReadonlyVec2} b The origin of the rotation
7348
+ * @param {Number} rad The angle of rotation in radians
7349
+ * @returns {vec2} out
7208
7350
  */
7209
7351
 
7210
- function fromMat3(out, m) {
7211
- // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
7212
- // article "Quaternion Calculus and Fast Animation".
7213
- var fTrace = m[0] + m[4] + m[8];
7214
- var fRoot;
7215
-
7216
- if (fTrace > 0.0) {
7217
- // |w| > 1/2, may as well choose w > 1/2
7218
- fRoot = Math.sqrt(fTrace + 1.0); // 2w
7352
+ function rotate(out, a, b, rad) {
7353
+ //Translate point to the origin
7354
+ var p0 = a[0] - b[0],
7355
+ p1 = a[1] - b[1],
7356
+ sinC = Math.sin(rad),
7357
+ cosC = Math.cos(rad); //perform rotation and translate to correct position
7219
7358
 
7220
- out[3] = 0.5 * fRoot;
7221
- fRoot = 0.5 / fRoot; // 1/(4w)
7359
+ out[0] = p0 * cosC - p1 * sinC + b[0];
7360
+ out[1] = p0 * sinC + p1 * cosC + b[1];
7361
+ return out;
7362
+ }
7363
+ /**
7364
+ * Get the angle between two 2D vectors
7365
+ * @param {ReadonlyVec2} a The first operand
7366
+ * @param {ReadonlyVec2} b The second operand
7367
+ * @returns {Number} The angle in radians
7368
+ */
7222
7369
 
7223
- out[0] = (m[5] - m[7]) * fRoot;
7224
- out[1] = (m[6] - m[2]) * fRoot;
7225
- out[2] = (m[1] - m[3]) * fRoot;
7226
- } else {
7227
- // |w| <= 1/2
7228
- var i = 0;
7229
- if (m[4] > m[0]) i = 1;
7230
- if (m[8] > m[i * 3 + i]) i = 2;
7231
- var j = (i + 1) % 3;
7232
- var k = (i + 2) % 3;
7233
- fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
7234
- out[i] = 0.5 * fRoot;
7235
- fRoot = 0.5 / fRoot;
7236
- out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
7237
- out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
7238
- out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
7239
- }
7370
+ function angle(a, b) {
7371
+ var x1 = a[0],
7372
+ y1 = a[1],
7373
+ x2 = b[0],
7374
+ y2 = b[1],
7375
+ // mag is the product of the magnitudes of a and b
7376
+ mag = Math.sqrt(x1 * x1 + y1 * y1) * Math.sqrt(x2 * x2 + y2 * y2),
7377
+ // mag &&.. short circuits if mag == 0
7378
+ cosine = mag && (x1 * x2 + y1 * y2) / mag; // Math.min(Math.max(cosine, -1), 1) clamps the cosine between -1 and 1
7240
7379
 
7241
- return out;
7380
+ return Math.acos(Math.min(Math.max(cosine, -1), 1));
7242
7381
  }
7243
7382
  /**
7244
- * Creates a quaternion from the given euler angle x, y, z.
7383
+ * Set the components of a vec2 to zero
7245
7384
  *
7246
- * @param {quat} out the receiving quaternion
7247
- * @param {x} Angle to rotate around X axis in degrees.
7248
- * @param {y} Angle to rotate around Y axis in degrees.
7249
- * @param {z} Angle to rotate around Z axis in degrees.
7250
- * @returns {quat} out
7251
- * @function
7385
+ * @param {vec2} out the receiving vector
7386
+ * @returns {vec2} out
7252
7387
  */
7253
7388
 
7254
- function fromEuler(out, x, y, z) {
7255
- var halfToRad = 0.5 * Math.PI / 180.0;
7256
- x *= halfToRad;
7257
- y *= halfToRad;
7258
- z *= halfToRad;
7259
- var sx = Math.sin(x);
7260
- var cx = Math.cos(x);
7261
- var sy = Math.sin(y);
7262
- var cy = Math.cos(y);
7263
- var sz = Math.sin(z);
7264
- var cz = Math.cos(z);
7265
- out[0] = sx * cy * cz - cx * sy * sz;
7266
- out[1] = cx * sy * cz + sx * cy * sz;
7267
- out[2] = cx * cy * sz - sx * sy * cz;
7268
- out[3] = cx * cy * cz + sx * sy * sz;
7389
+ function zero(out) {
7390
+ out[0] = 0.0;
7391
+ out[1] = 0.0;
7269
7392
  return out;
7270
7393
  }
7271
7394
  /**
7272
- * Returns a string representation of a quatenion
7395
+ * Returns a string representation of a vector
7273
7396
  *
7274
- * @param {ReadonlyQuat} a vector to represent as a string
7397
+ * @param {ReadonlyVec2} a vector to represent as a string
7275
7398
  * @returns {String} string representation of the vector
7276
7399
  */
7277
7400
 
7278
7401
  function str(a) {
7279
- return "quat(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")";
7402
+ return "vec2(" + a[0] + ", " + a[1] + ")";
7280
7403
  }
7281
7404
  /**
7282
- * Creates a new quat initialized with values from an existing quaternion
7283
- *
7284
- * @param {ReadonlyQuat} a quaternion to clone
7285
- * @returns {quat} a new quaternion
7286
- * @function
7287
- */
7288
-
7289
- var clone = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.clone;
7290
- /**
7291
- * Creates a new quat initialized with the given values
7405
+ * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
7292
7406
  *
7293
- * @param {Number} x X component
7294
- * @param {Number} y Y component
7295
- * @param {Number} z Z component
7296
- * @param {Number} w W component
7297
- * @returns {quat} a new quaternion
7298
- * @function
7407
+ * @param {ReadonlyVec2} a The first vector.
7408
+ * @param {ReadonlyVec2} b The second vector.
7409
+ * @returns {Boolean} True if the vectors are equal, false otherwise.
7299
7410
  */
7300
7411
 
7301
- var fromValues = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.fromValues;
7412
+ function exactEquals(a, b) {
7413
+ return a[0] === b[0] && a[1] === b[1];
7414
+ }
7302
7415
  /**
7303
- * Copy the values from one quat to another
7416
+ * Returns whether or not the vectors have approximately the same elements in the same position.
7304
7417
  *
7305
- * @param {quat} out the receiving quaternion
7306
- * @param {ReadonlyQuat} a the source quaternion
7307
- * @returns {quat} out
7308
- * @function
7418
+ * @param {ReadonlyVec2} a The first vector.
7419
+ * @param {ReadonlyVec2} b The second vector.
7420
+ * @returns {Boolean} True if the vectors are equal, false otherwise.
7309
7421
  */
7310
7422
 
7311
- var copy = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.copy;
7423
+ function equals(a, b) {
7424
+ var a0 = a[0],
7425
+ a1 = a[1];
7426
+ var b0 = b[0],
7427
+ b1 = b[1];
7428
+ return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));
7429
+ }
7312
7430
  /**
7313
- * Set the components of a quat to the given values
7314
- *
7315
- * @param {quat} out the receiving quaternion
7316
- * @param {Number} x X component
7317
- * @param {Number} y Y component
7318
- * @param {Number} z Z component
7319
- * @param {Number} w W component
7320
- * @returns {quat} out
7431
+ * Alias for {@link vec2.length}
7321
7432
  * @function
7322
7433
  */
7323
7434
 
7324
- var set = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.set;
7435
+ var len = (/* unused pure expression or super */ null && (length));
7325
7436
  /**
7326
- * Adds two quat's
7327
- *
7328
- * @param {quat} out the receiving quaternion
7329
- * @param {ReadonlyQuat} a the first operand
7330
- * @param {ReadonlyQuat} b the second operand
7331
- * @returns {quat} out
7437
+ * Alias for {@link vec2.subtract}
7332
7438
  * @function
7333
7439
  */
7334
7440
 
7335
- var add = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.add;
7441
+ var sub = (/* unused pure expression or super */ null && (subtract));
7336
7442
  /**
7337
- * Alias for {@link quat.multiply}
7443
+ * Alias for {@link vec2.multiply}
7338
7444
  * @function
7339
7445
  */
7340
7446
 
7341
7447
  var mul = (/* unused pure expression or super */ null && (multiply));
7342
7448
  /**
7343
- * Scales a quat by a scalar number
7344
- *
7345
- * @param {quat} out the receiving vector
7346
- * @param {ReadonlyQuat} a the vector to scale
7347
- * @param {Number} b amount to scale the vector by
7348
- * @returns {quat} out
7349
- * @function
7350
- */
7351
-
7352
- var scale = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.scale;
7353
- /**
7354
- * Calculates the dot product of two quat's
7355
- *
7356
- * @param {ReadonlyQuat} a the first operand
7357
- * @param {ReadonlyQuat} b the second operand
7358
- * @returns {Number} dot product of a and b
7359
- * @function
7360
- */
7361
-
7362
- var dot = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.dot;
7363
- /**
7364
- * Performs a linear interpolation between two quat's
7365
- *
7366
- * @param {quat} out the receiving quaternion
7367
- * @param {ReadonlyQuat} a the first operand
7368
- * @param {ReadonlyQuat} b the second operand
7369
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
7370
- * @returns {quat} out
7449
+ * Alias for {@link vec2.divide}
7371
7450
  * @function
7372
7451
  */
7373
7452
 
7374
- var lerp = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.lerp;
7375
- /**
7376
- * Calculates the length of a quat
7377
- *
7378
- * @param {ReadonlyQuat} a vector to calculate length of
7379
- * @returns {Number} length of a
7380
- */
7381
-
7382
- var length = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.length;
7453
+ var div = (/* unused pure expression or super */ null && (divide));
7383
7454
  /**
7384
- * Alias for {@link quat.length}
7455
+ * Alias for {@link vec2.distance}
7385
7456
  * @function
7386
7457
  */
7387
7458
 
7388
- var len = (/* unused pure expression or super */ null && (length));
7459
+ var dist = (/* unused pure expression or super */ null && (distance));
7389
7460
  /**
7390
- * Calculates the squared length of a quat
7391
- *
7392
- * @param {ReadonlyQuat} a vector to calculate squared length of
7393
- * @returns {Number} squared length of a
7461
+ * Alias for {@link vec2.squaredDistance}
7394
7462
  * @function
7395
7463
  */
7396
7464
 
7397
- var squaredLength = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.squaredLength;
7465
+ var sqrDist = (/* unused pure expression or super */ null && (squaredDistance));
7398
7466
  /**
7399
- * Alias for {@link quat.squaredLength}
7467
+ * Alias for {@link vec2.squaredLength}
7400
7468
  * @function
7401
7469
  */
7402
7470
 
7403
7471
  var sqrLen = (/* unused pure expression or super */ null && (squaredLength));
7404
7472
  /**
7405
- * Normalize a quat
7473
+ * Perform some operation over an array of vec2s.
7406
7474
  *
7407
- * @param {quat} out the receiving quaternion
7408
- * @param {ReadonlyQuat} a quaternion to normalize
7409
- * @returns {quat} out
7475
+ * @param {Array} a the array of vectors to iterate over
7476
+ * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
7477
+ * @param {Number} offset Number of elements to skip at the beginning of the array
7478
+ * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
7479
+ * @param {Function} fn Function to call for each vector in the array
7480
+ * @param {Object} [arg] additional argument to pass to fn
7481
+ * @returns {Array} a
7410
7482
  * @function
7411
7483
  */
7412
7484
 
7413
- var normalize = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.normalize;
7414
- /**
7415
- * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
7416
- *
7417
- * @param {ReadonlyQuat} a The first quaternion.
7418
- * @param {ReadonlyQuat} b The second quaternion.
7419
- * @returns {Boolean} True if the vectors are equal, false otherwise.
7420
- */
7421
-
7422
- var exactEquals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.exactEquals;
7423
- /**
7424
- * Returns whether or not the quaternions have approximately the same elements in the same position.
7425
- *
7426
- * @param {ReadonlyQuat} a The first vector.
7427
- * @param {ReadonlyQuat} b The second vector.
7428
- * @returns {Boolean} True if the vectors are equal, false otherwise.
7429
- */
7485
+ var forEach = function () {
7486
+ var vec = create();
7487
+ return function (a, stride, offset, count, fn, arg) {
7488
+ var i, l;
7430
7489
 
7431
- var equals = _vec4_js__WEBPACK_IMPORTED_MODULE_3__.equals;
7432
- /**
7433
- * Sets a quaternion to represent the shortest rotation from one
7434
- * vector to another.
7435
- *
7436
- * Both vectors are assumed to be unit length.
7437
- *
7438
- * @param {quat} out the receiving quaternion.
7439
- * @param {ReadonlyVec3} a the initial vector
7440
- * @param {ReadonlyVec3} b the destination vector
7441
- * @returns {quat} out
7442
- */
7490
+ if (!stride) {
7491
+ stride = 2;
7492
+ }
7443
7493
 
7444
- var rotationTo = function () {
7445
- var tmpvec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.create();
7446
- var xUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.fromValues(1, 0, 0);
7447
- var yUnitVec3 = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.fromValues(0, 1, 0);
7448
- return function (out, a, b) {
7449
- var dot = _vec3_js__WEBPACK_IMPORTED_MODULE_2__.dot(a, b);
7494
+ if (!offset) {
7495
+ offset = 0;
7496
+ }
7450
7497
 
7451
- if (dot < -0.999999) {
7452
- _vec3_js__WEBPACK_IMPORTED_MODULE_2__.cross(tmpvec3, xUnitVec3, a);
7453
- if (_vec3_js__WEBPACK_IMPORTED_MODULE_2__.len(tmpvec3) < 0.000001) _vec3_js__WEBPACK_IMPORTED_MODULE_2__.cross(tmpvec3, yUnitVec3, a);
7454
- _vec3_js__WEBPACK_IMPORTED_MODULE_2__.normalize(tmpvec3, tmpvec3);
7455
- setAxisAngle(out, tmpvec3, Math.PI);
7456
- return out;
7457
- } else if (dot > 0.999999) {
7458
- out[0] = 0;
7459
- out[1] = 0;
7460
- out[2] = 0;
7461
- out[3] = 1;
7462
- return out;
7498
+ if (count) {
7499
+ l = Math.min(count * stride + offset, a.length);
7463
7500
  } else {
7464
- _vec3_js__WEBPACK_IMPORTED_MODULE_2__.cross(tmpvec3, a, b);
7465
- out[0] = tmpvec3[0];
7466
- out[1] = tmpvec3[1];
7467
- out[2] = tmpvec3[2];
7468
- out[3] = 1 + dot;
7469
- return normalize(out, out);
7501
+ l = a.length;
7470
7502
  }
7471
- };
7472
- }();
7473
- /**
7474
- * Performs a spherical linear interpolation with two control points
7475
- *
7476
- * @param {quat} out the receiving quaternion
7477
- * @param {ReadonlyQuat} a the first operand
7478
- * @param {ReadonlyQuat} b the second operand
7479
- * @param {ReadonlyQuat} c the third operand
7480
- * @param {ReadonlyQuat} d the fourth operand
7481
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
7482
- * @returns {quat} out
7483
- */
7484
7503
 
7485
- var sqlerp = function () {
7486
- var temp1 = create();
7487
- var temp2 = create();
7488
- return function (out, a, b, c, d, t) {
7489
- slerp(temp1, a, d, t);
7490
- slerp(temp2, b, c, t);
7491
- slerp(out, temp1, temp2, 2 * t * (1 - t));
7492
- return out;
7493
- };
7494
- }();
7495
- /**
7496
- * Sets the specified quaternion with values corresponding to the given
7497
- * axes. Each axis is a vec3 and is expected to be unit length and
7498
- * perpendicular to all other specified axes.
7499
- *
7500
- * @param {ReadonlyVec3} view the vector representing the viewing direction
7501
- * @param {ReadonlyVec3} right the vector representing the local "right" direction
7502
- * @param {ReadonlyVec3} up the vector representing the local "up" direction
7503
- * @returns {quat} out
7504
- */
7504
+ for (i = offset; i < l; i += stride) {
7505
+ vec[0] = a[i];
7506
+ vec[1] = a[i + 1];
7507
+ fn(vec, vec, arg);
7508
+ a[i] = vec[0];
7509
+ a[i + 1] = vec[1];
7510
+ }
7505
7511
 
7506
- var setAxes = function () {
7507
- var matr = _mat3_js__WEBPACK_IMPORTED_MODULE_1__.create();
7508
- return function (out, view, right, up) {
7509
- matr[0] = right[0];
7510
- matr[3] = right[1];
7511
- matr[6] = right[2];
7512
- matr[1] = up[0];
7513
- matr[4] = up[1];
7514
- matr[7] = up[2];
7515
- matr[2] = -view[0];
7516
- matr[5] = -view[1];
7517
- matr[8] = -view[2];
7518
- return normalize(out, fromMat3(out, matr));
7512
+ return a;
7519
7513
  };
7520
7514
  }();
7521
7515