@vertexvis/geometry 1.0.2-canary.0 → 1.0.2-canary.10
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.
- package/dist/bundle.cjs +259 -244
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.js +259 -242
- package/dist/bundle.js.map +1 -1
- package/dist/cdn/bundle.js +259 -242
- package/dist/cdn/bundle.js.map +1 -1
- package/dist/cdn/bundle.min.js +1 -1
- package/dist/cdn/bundle.min.js.map +1 -1
- package/dist/euler.d.ts +1 -1
- package/dist/matrix4.d.ts +33 -25
- package/dist/vector3.d.ts +17 -1
- package/package.json +4 -4
package/dist/bundle.js
CHANGED
|
@@ -172,21 +172,21 @@ function fromJson$5(json) {
|
|
|
172
172
|
|
|
173
173
|
var point = /*#__PURE__*/Object.freeze({
|
|
174
174
|
__proto__: null,
|
|
175
|
+
add: add$1,
|
|
175
176
|
create: create$d,
|
|
176
|
-
polar: polar,
|
|
177
177
|
distance: distance$2,
|
|
178
|
-
|
|
179
|
-
add: add$1,
|
|
178
|
+
fromJson: fromJson$5,
|
|
180
179
|
isEqual: isEqual$3,
|
|
181
180
|
lerp: lerp$1,
|
|
182
|
-
negate: negate$1,
|
|
183
|
-
scale: scale$5,
|
|
184
|
-
scaleProportional: scaleProportional,
|
|
185
181
|
magnitude: magnitude$2,
|
|
186
|
-
|
|
182
|
+
negate: negate$1,
|
|
187
183
|
normalDirectionVector: normalDirectionVector,
|
|
184
|
+
normalizeVector: normalizeVector,
|
|
188
185
|
orthogonalVector: orthogonalVector,
|
|
189
|
-
|
|
186
|
+
polar: polar,
|
|
187
|
+
scale: scale$5,
|
|
188
|
+
scaleProportional: scaleProportional,
|
|
189
|
+
subtract: subtract$1
|
|
190
190
|
});
|
|
191
191
|
|
|
192
192
|
/**
|
|
@@ -257,10 +257,10 @@ function fromValues(
|
|
|
257
257
|
m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
|
|
258
258
|
/* eslint-disable prettier/prettier */
|
|
259
259
|
return [
|
|
260
|
-
m11,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
m11, m12, m13, m14,
|
|
261
|
+
m21, m22, m23, m24,
|
|
262
|
+
m31, m32, m33, m34,
|
|
263
|
+
m41, m42, m43, m44,
|
|
264
264
|
];
|
|
265
265
|
/* eslint-enable prettier/prettier */
|
|
266
266
|
}
|
|
@@ -330,9 +330,9 @@ function makeRotation(rotation) {
|
|
|
330
330
|
var wx = w * x2, wy = w * y2, wz = w * z2;
|
|
331
331
|
/* eslint-disable prettier/prettier */
|
|
332
332
|
return [
|
|
333
|
-
1 - (yy + zz), xy
|
|
334
|
-
xy
|
|
335
|
-
xz
|
|
333
|
+
1 - (yy + zz), xy - wz, xz + wy, 0,
|
|
334
|
+
xy + wz, 1 - (xx + zz), yz - wx, 0,
|
|
335
|
+
xz - wy, yz + wx, 1 - (xx + yy), 0,
|
|
336
336
|
0, 0, 0, 1
|
|
337
337
|
];
|
|
338
338
|
/* eslint-enable prettier/prettier */
|
|
@@ -362,33 +362,33 @@ function makeScale(scale) {
|
|
|
362
362
|
/* eslint-enable prettier/prettier */
|
|
363
363
|
}
|
|
364
364
|
/**
|
|
365
|
-
* Creates a matrix that has translation, rotation and scale applied to it.
|
|
365
|
+
* Creates a matrix that has translation, rotation, and scale applied to it.
|
|
366
366
|
*
|
|
367
367
|
* @param translation The translation applied to the matrix.
|
|
368
368
|
* @param rotation The rotation applied to the matrix.
|
|
369
369
|
* @param scale The scale applied to the matrix.
|
|
370
|
-
* @returns A transformed matrix.
|
|
370
|
+
* @returns A transformed matrix in column-major form.
|
|
371
371
|
*/
|
|
372
372
|
function makeTRS(translation, rotation, scale) {
|
|
373
373
|
var t = makeTranslation(translation);
|
|
374
|
-
var r = makeRotation(rotation);
|
|
374
|
+
var r = transpose(makeRotation(rotation));
|
|
375
375
|
var s = makeScale(scale);
|
|
376
|
-
return multiply$2(multiply$2(
|
|
376
|
+
return multiply$2(s, multiply$2(r, t));
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
* Returns a matrix that has the basis components (upper left 3x3 matrix) set to
|
|
380
380
|
* the following x, y, and z axis.
|
|
381
381
|
*
|
|
382
382
|
* ```
|
|
383
|
-
* x.x y.
|
|
384
|
-
* x.y y.
|
|
385
|
-
* x.
|
|
383
|
+
* x.x x.y x.z 0
|
|
384
|
+
* y.x y.y y.z 0
|
|
385
|
+
* z.x z.y z.z 0
|
|
386
386
|
* 0 0 0 0
|
|
387
387
|
* ```
|
|
388
388
|
*
|
|
389
|
-
* @param x The x
|
|
390
|
-
* @param y The y
|
|
391
|
-
* @param z The z
|
|
389
|
+
* @param x The x-axis to set.
|
|
390
|
+
* @param y The y-axis to set.
|
|
391
|
+
* @param z The z-axis to set.
|
|
392
392
|
* @returns A matrix with its basis components populated.
|
|
393
393
|
*/
|
|
394
394
|
function makeBasis(x, y, z) {
|
|
@@ -401,30 +401,6 @@ function makeBasis(x, y, z) {
|
|
|
401
401
|
];
|
|
402
402
|
/* eslint-enable prettier/prettier */
|
|
403
403
|
}
|
|
404
|
-
/**
|
|
405
|
-
* Creates a rotation matrix that is rotated around a given axis by the given
|
|
406
|
-
* angle.
|
|
407
|
-
*
|
|
408
|
-
* @param axis The axis of rotation.
|
|
409
|
-
* @param radians The angle of rotation.
|
|
410
|
-
* @returns A rotation matrix.
|
|
411
|
-
*/
|
|
412
|
-
function makeRotationAxis(axis, radians) {
|
|
413
|
-
var c = Math.cos(radians);
|
|
414
|
-
var s = Math.sin(radians);
|
|
415
|
-
var t = 1 - c;
|
|
416
|
-
var x = axis.x, y = axis.y, z = axis.z;
|
|
417
|
-
var tx = t * x;
|
|
418
|
-
var ty = t * y;
|
|
419
|
-
/* eslint-disable prettier/prettier */
|
|
420
|
-
return [
|
|
421
|
-
tx * x + c, tx * y + s * z, tx * z - s * y, 0,
|
|
422
|
-
tx * y - s * z, ty * y + c, ty * z + s * x, 0,
|
|
423
|
-
tx * z + s * y, ty * z - s * x, t * z * z + c, 0,
|
|
424
|
-
0, 0, 0, 1
|
|
425
|
-
];
|
|
426
|
-
/* eslint-enable prettier/prettier */
|
|
427
|
-
}
|
|
428
404
|
/**
|
|
429
405
|
* Creates a matrix used for [perspective
|
|
430
406
|
* projections](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).
|
|
@@ -606,24 +582,24 @@ function invert(matrix) {
|
|
|
606
582
|
if (!det) {
|
|
607
583
|
return makeZero();
|
|
608
584
|
}
|
|
609
|
-
|
|
585
|
+
var oneOverDet = 1 / det;
|
|
610
586
|
return [
|
|
611
|
-
(a11 * b11 - a12 * b10 + a13 * b09) *
|
|
612
|
-
(a02 * b10 - a01 * b11 - a03 * b09) *
|
|
613
|
-
(a31 * b05 - a32 * b04 + a33 * b03) *
|
|
614
|
-
(a22 * b04 - a21 * b05 - a23 * b03) *
|
|
615
|
-
(a12 * b08 - a10 * b11 - a13 * b07) *
|
|
616
|
-
(a00 * b11 - a02 * b08 + a03 * b07) *
|
|
617
|
-
(a32 * b02 - a30 * b05 - a33 * b01) *
|
|
618
|
-
(a20 * b05 - a22 * b02 + a23 * b01) *
|
|
619
|
-
(a10 * b10 - a11 * b08 + a13 * b06) *
|
|
620
|
-
(a01 * b08 - a00 * b10 - a03 * b06) *
|
|
621
|
-
(a30 * b04 - a31 * b02 + a33 * b00) *
|
|
622
|
-
(a21 * b02 - a20 * b04 - a23 * b00) *
|
|
623
|
-
(a11 * b07 - a10 * b09 - a12 * b06) *
|
|
624
|
-
(a00 * b09 - a01 * b07 + a02 * b06) *
|
|
625
|
-
(a31 * b01 - a30 * b03 - a32 * b00) *
|
|
626
|
-
(a20 * b03 - a21 * b01 + a22 * b00) *
|
|
587
|
+
(a11 * b11 - a12 * b10 + a13 * b09) * oneOverDet,
|
|
588
|
+
(a02 * b10 - a01 * b11 - a03 * b09) * oneOverDet,
|
|
589
|
+
(a31 * b05 - a32 * b04 + a33 * b03) * oneOverDet,
|
|
590
|
+
(a22 * b04 - a21 * b05 - a23 * b03) * oneOverDet,
|
|
591
|
+
(a12 * b08 - a10 * b11 - a13 * b07) * oneOverDet,
|
|
592
|
+
(a00 * b11 - a02 * b08 + a03 * b07) * oneOverDet,
|
|
593
|
+
(a32 * b02 - a30 * b05 - a33 * b01) * oneOverDet,
|
|
594
|
+
(a20 * b05 - a22 * b02 + a23 * b01) * oneOverDet,
|
|
595
|
+
(a10 * b10 - a11 * b08 + a13 * b06) * oneOverDet,
|
|
596
|
+
(a01 * b08 - a00 * b10 - a03 * b06) * oneOverDet,
|
|
597
|
+
(a30 * b04 - a31 * b02 + a33 * b00) * oneOverDet,
|
|
598
|
+
(a21 * b02 - a20 * b04 - a23 * b00) * oneOverDet,
|
|
599
|
+
(a11 * b07 - a10 * b09 - a12 * b06) * oneOverDet,
|
|
600
|
+
(a00 * b09 - a01 * b07 + a02 * b06) * oneOverDet,
|
|
601
|
+
(a31 * b01 - a30 * b03 - a32 * b00) * oneOverDet,
|
|
602
|
+
(a20 * b03 - a21 * b01 + a22 * b00) * oneOverDet,
|
|
627
603
|
];
|
|
628
604
|
}
|
|
629
605
|
/**
|
|
@@ -658,49 +634,37 @@ function lookAt(m, position, target, up) {
|
|
|
658
634
|
var res = __spreadArray([], m, true);
|
|
659
635
|
/* eslint-disable prettier/prettier */
|
|
660
636
|
res[0] = x.x;
|
|
661
|
-
res[4] = y.x;
|
|
662
|
-
res[8] = z.x;
|
|
663
637
|
res[1] = x.y;
|
|
664
|
-
res[5] = y.y;
|
|
665
|
-
res[9] = z.y;
|
|
666
638
|
res[2] = x.z;
|
|
639
|
+
res[4] = y.x;
|
|
640
|
+
res[5] = y.y;
|
|
667
641
|
res[6] = y.z;
|
|
642
|
+
res[8] = z.x;
|
|
643
|
+
res[9] = z.y;
|
|
668
644
|
res[10] = z.z;
|
|
669
645
|
/* eslint-enable prettier/prettier */
|
|
670
646
|
return res;
|
|
671
647
|
}
|
|
672
648
|
/**
|
|
673
|
-
* Returns a post-multiplied matrix.
|
|
649
|
+
* Returns a post-multiplied matrix equal to ab.
|
|
674
650
|
*/
|
|
675
651
|
function multiply$2(a, b) {
|
|
676
|
-
var
|
|
677
|
-
|
|
678
|
-
var
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
mat[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
|
|
693
|
-
mat[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
|
|
694
|
-
mat[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
|
|
695
|
-
mat[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
|
|
696
|
-
mat[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
|
|
697
|
-
mat[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
|
|
698
|
-
mat[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
|
|
699
|
-
mat[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
|
|
700
|
-
mat[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
|
|
701
|
-
mat[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
|
|
702
|
-
mat[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
|
|
703
|
-
return mat;
|
|
652
|
+
var result = makeIdentity();
|
|
653
|
+
// Consider each row i in the final matrix
|
|
654
|
+
for (var i = 0; i < 4; i++) {
|
|
655
|
+
// Consider each column j in the final matrix
|
|
656
|
+
for (var j = 0; j < 4; j++) {
|
|
657
|
+
// Calculate the value at row i and column j
|
|
658
|
+
var value = 0;
|
|
659
|
+
for (var k = 0; k < 4; k++) {
|
|
660
|
+
// Calculate (ik + kj) and add it to the value
|
|
661
|
+
value += a[i * 4 + k] * b[k * 4 + j];
|
|
662
|
+
}
|
|
663
|
+
var positionInResultingMatrix = 4 * i + j;
|
|
664
|
+
result[positionInResultingMatrix] = value;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return result;
|
|
704
668
|
}
|
|
705
669
|
/**
|
|
706
670
|
* Returns the [transpose](https://en.wikipedia.org/wiki/Transpose) of the given
|
|
@@ -717,32 +681,37 @@ function transpose(matrix) {
|
|
|
717
681
|
/* eslint-enable prettier/prettier */
|
|
718
682
|
}
|
|
719
683
|
/**
|
|
720
|
-
* Multiplies the columns of a matrix by the given vector.
|
|
684
|
+
* Multiplies the columns of a row-major matrix by the given vector.
|
|
721
685
|
*/
|
|
722
686
|
function scale$4(matrix, scale) {
|
|
723
687
|
var x = scale.x, y = scale.y, z = scale.z;
|
|
724
688
|
var m = __spreadArray([], matrix, true);
|
|
725
689
|
/* eslint-disable prettier/prettier */
|
|
726
690
|
m[0] *= x;
|
|
727
|
-
m[4] *= y;
|
|
728
|
-
m[8] *= z;
|
|
729
691
|
m[1] *= x;
|
|
730
|
-
m[5] *= y;
|
|
731
|
-
m[9] *= z;
|
|
732
692
|
m[2] *= x;
|
|
733
|
-
m[6] *= y;
|
|
734
|
-
m[10] *= z;
|
|
735
693
|
m[3] *= x;
|
|
694
|
+
m[4] *= y;
|
|
695
|
+
m[5] *= y;
|
|
696
|
+
m[6] *= y;
|
|
736
697
|
m[7] *= y;
|
|
698
|
+
m[8] *= z;
|
|
699
|
+
m[9] *= z;
|
|
700
|
+
m[10] *= z;
|
|
737
701
|
m[11] *= z;
|
|
738
702
|
/* eslint-enable prettier/prettier */
|
|
739
703
|
return m;
|
|
740
704
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
705
|
+
/**
|
|
706
|
+
* Sets the position of the matrix given as the first parameter
|
|
707
|
+
* to the position of the matrix given as the second parameter.
|
|
708
|
+
* Both matrices should have row-major format.
|
|
709
|
+
*/
|
|
710
|
+
function position(originalMatrix, matrixWithDesiredPosition) {
|
|
711
|
+
var m = __spreadArray([], originalMatrix, true);
|
|
712
|
+
m[12] = matrixWithDesiredPosition[12];
|
|
713
|
+
m[13] = matrixWithDesiredPosition[13];
|
|
714
|
+
m[14] = matrixWithDesiredPosition[14];
|
|
746
715
|
return m;
|
|
747
716
|
}
|
|
748
717
|
/**
|
|
@@ -754,8 +723,18 @@ function isIdentity(matrix) {
|
|
|
754
723
|
}
|
|
755
724
|
/**
|
|
756
725
|
* Returns an object representation of a `Matrix4`.
|
|
726
|
+
* @param m A Matrix4 item written in column-major form.
|
|
727
|
+
*
|
|
728
|
+
* @deprecated Use {@link toObjectColumnMajor} or {@link toObjectRowMajor} instead.
|
|
757
729
|
*/
|
|
758
730
|
function toObject(m) {
|
|
731
|
+
return toObjectColumnMajor(m);
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Returns an object representation of a `Matrix4`.
|
|
735
|
+
* @param m A Matrix4 item written in column-major form.
|
|
736
|
+
*/
|
|
737
|
+
function toObjectColumnMajor(m) {
|
|
759
738
|
/* eslint-disable prettier/prettier */
|
|
760
739
|
return {
|
|
761
740
|
m11: m[0], m12: m[4], m13: m[8], m14: m[12],
|
|
@@ -765,6 +744,20 @@ function toObject(m) {
|
|
|
765
744
|
};
|
|
766
745
|
/* eslint-enable prettier/prettier */
|
|
767
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* Returns an object representation of a `Matrix4`.
|
|
749
|
+
* @param m A Matrix4 item written in row-major form.
|
|
750
|
+
*/
|
|
751
|
+
function toObjectRowMajor(m) {
|
|
752
|
+
/* eslint-disable prettier/prettier */
|
|
753
|
+
return {
|
|
754
|
+
m11: m[0], m12: m[1], m13: m[2], m14: m[3],
|
|
755
|
+
m21: m[4], m22: m[5], m23: m[6], m24: m[7],
|
|
756
|
+
m31: m[8], m32: m[9], m33: m[10], m34: m[11],
|
|
757
|
+
m41: m[12], m42: m[13], m43: m[14], m44: m[15],
|
|
758
|
+
};
|
|
759
|
+
/* eslint-enable prettier/prettier */
|
|
760
|
+
}
|
|
768
761
|
/**
|
|
769
762
|
* A type guard to check if `obj` is of type `Matrix4`.
|
|
770
763
|
*/
|
|
@@ -774,30 +767,31 @@ function isType$2(obj) {
|
|
|
774
767
|
|
|
775
768
|
var matrix4 = /*#__PURE__*/Object.freeze({
|
|
776
769
|
__proto__: null,
|
|
777
|
-
fromValues: fromValues,
|
|
778
770
|
fromObject: fromObject,
|
|
771
|
+
fromValues: fromValues,
|
|
772
|
+
invert: invert,
|
|
773
|
+
isIdentity: isIdentity,
|
|
774
|
+
isType: isType$2,
|
|
775
|
+
lookAt: lookAt,
|
|
776
|
+
makeBasis: makeBasis,
|
|
777
|
+
makeFrustum: makeFrustum,
|
|
779
778
|
makeIdentity: makeIdentity,
|
|
780
|
-
|
|
781
|
-
|
|
779
|
+
makeLookAt: makeLookAt,
|
|
780
|
+
makeLookAtView: makeLookAtView,
|
|
781
|
+
makeOrthographic: makeOrthographic,
|
|
782
|
+
makePerspective: makePerspective,
|
|
782
783
|
makeRotation: makeRotation,
|
|
783
784
|
makeScale: makeScale,
|
|
784
785
|
makeTRS: makeTRS,
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
makeFrustum: makeFrustum,
|
|
788
|
-
makePerspective: makePerspective,
|
|
789
|
-
makeOrthographic: makeOrthographic,
|
|
790
|
-
makeLookAtView: makeLookAtView,
|
|
791
|
-
makeLookAt: makeLookAt,
|
|
792
|
-
invert: invert,
|
|
793
|
-
lookAt: lookAt,
|
|
786
|
+
makeTranslation: makeTranslation,
|
|
787
|
+
makeZero: makeZero,
|
|
794
788
|
multiply: multiply$2,
|
|
795
|
-
transpose: transpose,
|
|
796
|
-
scale: scale$4,
|
|
797
789
|
position: position,
|
|
798
|
-
|
|
790
|
+
scale: scale$4,
|
|
799
791
|
toObject: toObject,
|
|
800
|
-
|
|
792
|
+
toObjectColumnMajor: toObjectColumnMajor,
|
|
793
|
+
toObjectRowMajor: toObjectRowMajor,
|
|
794
|
+
transpose: transpose
|
|
801
795
|
});
|
|
802
796
|
|
|
803
797
|
/**
|
|
@@ -847,9 +841,12 @@ function fromDegrees(value) {
|
|
|
847
841
|
* @param matrix A pure rotation matrix, unscaled.
|
|
848
842
|
* @param order The order that the rotations are applied.
|
|
849
843
|
*/
|
|
850
|
-
function fromRotationMatrix(matrix, order) {
|
|
844
|
+
function fromRotationMatrix(matrix, order, matrixIsColumnMajor) {
|
|
851
845
|
if (order === void 0) { order = 'xyz'; }
|
|
852
|
-
|
|
846
|
+
if (matrixIsColumnMajor === void 0) { matrixIsColumnMajor = true; }
|
|
847
|
+
var m = matrixIsColumnMajor
|
|
848
|
+
? toObjectColumnMajor(matrix)
|
|
849
|
+
: toObjectRowMajor(matrix);
|
|
853
850
|
var x = 0, y = 0, z = 0;
|
|
854
851
|
if (order === 'xyz') {
|
|
855
852
|
y = Math.asin(clamp(m.m13, -1, 1));
|
|
@@ -955,8 +952,8 @@ var euler = /*#__PURE__*/Object.freeze({
|
|
|
955
952
|
__proto__: null,
|
|
956
953
|
create: create$c,
|
|
957
954
|
fromDegrees: fromDegrees,
|
|
958
|
-
fromRotationMatrix: fromRotationMatrix,
|
|
959
955
|
fromJson: fromJson$4,
|
|
956
|
+
fromRotationMatrix: fromRotationMatrix,
|
|
960
957
|
isType: isType$1
|
|
961
958
|
});
|
|
962
959
|
|
|
@@ -1028,55 +1025,47 @@ function fromAxisAngle(axis, radians) {
|
|
|
1028
1025
|
* (unscaled).
|
|
1029
1026
|
*/
|
|
1030
1027
|
function fromMatrixRotation(matrix) {
|
|
1031
|
-
|
|
1028
|
+
// Determine the scalars for each vector
|
|
1032
1029
|
var scale = fromMatrixScale(matrix);
|
|
1033
|
-
var
|
|
1034
|
-
|
|
1035
|
-
var
|
|
1036
|
-
var
|
|
1037
|
-
var
|
|
1038
|
-
var sm13 = m.m31 * is3;
|
|
1039
|
-
var sm21 = m.m12 * is1;
|
|
1040
|
-
var sm22 = m.m22 * is2;
|
|
1041
|
-
var sm23 = m.m32 * is3;
|
|
1042
|
-
var sm31 = m.m13 * is1;
|
|
1043
|
-
var sm32 = m.m23 * is2;
|
|
1044
|
-
var sm33 = m.m33 * is3;
|
|
1045
|
-
var trace = sm11 + sm22 + sm33;
|
|
1030
|
+
var oneOverScaleVector = create$a(1 / scale.x, 1 / scale.y, 1 / scale.z);
|
|
1031
|
+
// Scale the matrix
|
|
1032
|
+
var scaledMatrix = scale$4(matrix, oneOverScaleVector);
|
|
1033
|
+
var sM = toObjectRowMajor(scaledMatrix);
|
|
1034
|
+
var trace = sM.m11 + sM.m22 + sM.m33;
|
|
1046
1035
|
if (trace > 0) {
|
|
1047
|
-
var s = Math.sqrt(trace + 1
|
|
1036
|
+
var s = Math.sqrt(trace + 1) * 2;
|
|
1048
1037
|
return {
|
|
1049
|
-
x: (
|
|
1050
|
-
y: (
|
|
1051
|
-
z: (
|
|
1038
|
+
x: (sM.m23 - sM.m32) / s,
|
|
1039
|
+
y: (sM.m31 - sM.m13) / s,
|
|
1040
|
+
z: (sM.m12 - sM.m21) / s,
|
|
1052
1041
|
w: 0.25 * s,
|
|
1053
1042
|
};
|
|
1054
1043
|
}
|
|
1055
|
-
else if (
|
|
1056
|
-
var s = Math.sqrt(1
|
|
1044
|
+
else if (sM.m11 > sM.m22 && sM.m11 > sM.m33) {
|
|
1045
|
+
var s = Math.sqrt(1 + sM.m11 - sM.m22 - sM.m33) * 2;
|
|
1057
1046
|
return {
|
|
1058
1047
|
x: 0.25 * s,
|
|
1059
|
-
y: (
|
|
1060
|
-
z: (
|
|
1061
|
-
w: (
|
|
1048
|
+
y: (sM.m12 + sM.m21) / s,
|
|
1049
|
+
z: (sM.m31 + sM.m13) / s,
|
|
1050
|
+
w: (sM.m23 - sM.m32) / s,
|
|
1062
1051
|
};
|
|
1063
1052
|
}
|
|
1064
|
-
else if (
|
|
1065
|
-
var s = Math.sqrt(1
|
|
1053
|
+
else if (sM.m22 > sM.m33) {
|
|
1054
|
+
var s = Math.sqrt(1 + sM.m22 - sM.m11 - sM.m33) * 2;
|
|
1066
1055
|
return {
|
|
1067
|
-
x: (
|
|
1056
|
+
x: (sM.m12 + sM.m21) / s,
|
|
1068
1057
|
y: 0.25 * s,
|
|
1069
|
-
z: (
|
|
1070
|
-
w: (
|
|
1058
|
+
z: (sM.m23 + sM.m32) / s,
|
|
1059
|
+
w: (sM.m31 - sM.m13) / s,
|
|
1071
1060
|
};
|
|
1072
1061
|
}
|
|
1073
1062
|
else {
|
|
1074
|
-
var s = Math.sqrt(1
|
|
1063
|
+
var s = Math.sqrt(1 + sM.m33 - sM.m11 - sM.m22) * 2;
|
|
1075
1064
|
return {
|
|
1076
|
-
x: (
|
|
1077
|
-
y: (
|
|
1065
|
+
x: (sM.m31 + sM.m13) / s,
|
|
1066
|
+
y: (sM.m23 + sM.m32) / s,
|
|
1078
1067
|
z: 0.25 * s,
|
|
1079
|
-
w: (
|
|
1068
|
+
w: (sM.m12 - sM.m21) / s,
|
|
1080
1069
|
};
|
|
1081
1070
|
}
|
|
1082
1071
|
}
|
|
@@ -1157,15 +1146,15 @@ function isType(obj) {
|
|
|
1157
1146
|
var quaternion = /*#__PURE__*/Object.freeze({
|
|
1158
1147
|
__proto__: null,
|
|
1159
1148
|
create: create$b,
|
|
1160
|
-
fromJson: fromJson$3,
|
|
1161
|
-
normalize: normalize$1,
|
|
1162
|
-
magnitude: magnitude$1,
|
|
1163
|
-
scale: scale$3,
|
|
1164
1149
|
fromAxisAngle: fromAxisAngle,
|
|
1165
|
-
fromMatrixRotation: fromMatrixRotation,
|
|
1166
1150
|
fromEuler: fromEuler,
|
|
1151
|
+
fromJson: fromJson$3,
|
|
1152
|
+
fromMatrixRotation: fromMatrixRotation,
|
|
1153
|
+
isType: isType,
|
|
1154
|
+
magnitude: magnitude$1,
|
|
1167
1155
|
multiply: multiply$1,
|
|
1168
|
-
|
|
1156
|
+
normalize: normalize$1,
|
|
1157
|
+
scale: scale$3
|
|
1169
1158
|
});
|
|
1170
1159
|
|
|
1171
1160
|
function create$a() {
|
|
@@ -1208,19 +1197,19 @@ function isValid$1(_a) {
|
|
|
1208
1197
|
* Returns a vector representing the scale elements of `matrix`.
|
|
1209
1198
|
*/
|
|
1210
1199
|
function fromMatrixScale(matrix) {
|
|
1211
|
-
var m =
|
|
1200
|
+
var m = toObjectRowMajor(matrix);
|
|
1212
1201
|
return {
|
|
1213
|
-
x: Math.hypot(m.m11, m.
|
|
1214
|
-
y: Math.hypot(m.
|
|
1215
|
-
z: Math.hypot(m.
|
|
1202
|
+
x: Math.hypot(m.m11, m.m12, m.m13),
|
|
1203
|
+
y: Math.hypot(m.m21, m.m22, m.m23),
|
|
1204
|
+
z: Math.hypot(m.m31, m.m32, m.m33),
|
|
1216
1205
|
};
|
|
1217
1206
|
}
|
|
1218
1207
|
/**
|
|
1219
1208
|
* Returns a vector representing the position elements of `matrix`.
|
|
1220
1209
|
*/
|
|
1221
1210
|
function fromMatrixPosition(matrix) {
|
|
1222
|
-
var m =
|
|
1223
|
-
return { x: m.
|
|
1211
|
+
var m = toObjectRowMajor(matrix);
|
|
1212
|
+
return { x: m.m41, y: m.m42, z: m.m43 };
|
|
1224
1213
|
}
|
|
1225
1214
|
/**
|
|
1226
1215
|
* Parses a JSON string representation of a Vector3 and returns an object.
|
|
@@ -1418,7 +1407,7 @@ function eulerTo(a, b) {
|
|
|
1418
1407
|
return dotAB > 1 - 1e-6 ? create$c() : create$c({ x: Math.PI });
|
|
1419
1408
|
}
|
|
1420
1409
|
var normalizedQ = normalize$1(create$b(__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
|
|
1421
|
-
return fromRotationMatrix(makeRotation(normalizedQ));
|
|
1410
|
+
return fromRotationMatrix(makeRotation(normalizedQ), 'xyz', false);
|
|
1422
1411
|
}
|
|
1423
1412
|
/**
|
|
1424
1413
|
* Performs a projection of a `vector` onto `onNormal`.
|
|
@@ -1470,9 +1459,21 @@ function rotateAboutAxis(angle, point, axisDirection, axisPosition) {
|
|
|
1470
1459
|
}
|
|
1471
1460
|
}
|
|
1472
1461
|
/**
|
|
1473
|
-
* Returns a vector that is multiplied with a matrix.
|
|
1462
|
+
* Returns a vector that is multiplied with a matrix in column-major form.
|
|
1463
|
+
* @param vector A Vector3 item.
|
|
1464
|
+
* @param m A Matrix4 item written in column-major form.
|
|
1465
|
+
*
|
|
1466
|
+
* @deprecated Use {@link multiplyByTransformMatrixColumnMajor} or {@link multiplyByTransformMatrixRowMajor} instead.
|
|
1474
1467
|
*/
|
|
1475
1468
|
function transformMatrix$1(vector, m) {
|
|
1469
|
+
return multiplyByTransformMatrixColumnMajor(vector, m);
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Returns a vector that is multiplied with a matrix in column-major form.
|
|
1473
|
+
* @param vector A Vector3 item.
|
|
1474
|
+
* @param m A Matrix4 item written in column-major form.
|
|
1475
|
+
*/
|
|
1476
|
+
function multiplyByTransformMatrixColumnMajor(vector, m) {
|
|
1476
1477
|
var x = vector.x, y = vector.y, z = vector.z;
|
|
1477
1478
|
var w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
|
|
1478
1479
|
return {
|
|
@@ -1481,6 +1482,20 @@ function transformMatrix$1(vector, m) {
|
|
|
1481
1482
|
z: (m[2] * x + m[6] * y + m[10] * z + m[14]) * w,
|
|
1482
1483
|
};
|
|
1483
1484
|
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Returns a vector that is multiplied with a matrix in row-major form.
|
|
1487
|
+
* @param vector A Vector3 item.
|
|
1488
|
+
* @param m A Matrix4 item written in row-major form.
|
|
1489
|
+
*/
|
|
1490
|
+
function multiplyByTransformMatrixRowMajor(vector, m) {
|
|
1491
|
+
var x = vector.x, y = vector.y, z = vector.z;
|
|
1492
|
+
var w = 1 / (m[12] * x + m[13] * y + m[14] * z + m[15]);
|
|
1493
|
+
return {
|
|
1494
|
+
x: (m[0] * x + m[1] * y + m[2] * z + m[3]) * w,
|
|
1495
|
+
y: (m[4] * x + m[5] * y + m[6] * z + m[7]) * w,
|
|
1496
|
+
z: (m[8] * x + m[9] * y + m[10] * z + m[11]) * w,
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1484
1499
|
/**
|
|
1485
1500
|
* Euclidean distance between two vectors
|
|
1486
1501
|
*/
|
|
@@ -1544,47 +1559,49 @@ function lerp(a, b, t) {
|
|
|
1544
1559
|
* @returns A point in world space coordinates.
|
|
1545
1560
|
*/
|
|
1546
1561
|
function transformNdcToWorldSpace(ndc, worldMatrix, projectionMatrixInverse) {
|
|
1547
|
-
return
|
|
1562
|
+
return multiplyByTransformMatrixColumnMajor(multiplyByTransformMatrixColumnMajor(ndc, projectionMatrixInverse), worldMatrix);
|
|
1548
1563
|
}
|
|
1549
1564
|
|
|
1550
1565
|
var vector3 = /*#__PURE__*/Object.freeze({
|
|
1551
1566
|
__proto__: null,
|
|
1567
|
+
add: add,
|
|
1568
|
+
angleTo: angleTo,
|
|
1569
|
+
back: back,
|
|
1552
1570
|
create: create$a,
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
right: right,
|
|
1560
|
-
up: up,
|
|
1571
|
+
cross: cross,
|
|
1572
|
+
distance: distance$1,
|
|
1573
|
+
distanceSquared: distanceSquared$1,
|
|
1574
|
+
dot: dot$1,
|
|
1575
|
+
down: down,
|
|
1576
|
+
eulerTo: eulerTo,
|
|
1561
1577
|
forward: forward,
|
|
1578
|
+
fromArray: fromArray,
|
|
1579
|
+
fromJson: fromJson$2,
|
|
1580
|
+
fromMatrixPosition: fromMatrixPosition,
|
|
1581
|
+
fromMatrixScale: fromMatrixScale,
|
|
1582
|
+
isEqual: isEqual$2,
|
|
1583
|
+
isValid: isValid$1,
|
|
1562
1584
|
left: left,
|
|
1563
|
-
|
|
1564
|
-
back: back,
|
|
1565
|
-
origin: origin,
|
|
1566
|
-
normalize: normalize,
|
|
1585
|
+
lerp: lerp,
|
|
1567
1586
|
magnitude: magnitude,
|
|
1568
1587
|
magnitudeSquared: magnitudeSquared,
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
subtract: subtract,
|
|
1588
|
+
max: max,
|
|
1589
|
+
min: min,
|
|
1572
1590
|
multiply: multiply,
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1591
|
+
multiplyByTransformMatrixColumnMajor: multiplyByTransformMatrixColumnMajor,
|
|
1592
|
+
multiplyByTransformMatrixRowMajor: multiplyByTransformMatrixRowMajor,
|
|
1593
|
+
negate: negate,
|
|
1594
|
+
normalize: normalize,
|
|
1595
|
+
origin: origin,
|
|
1577
1596
|
project: project,
|
|
1597
|
+
right: right,
|
|
1578
1598
|
rotateAboutAxis: rotateAboutAxis,
|
|
1599
|
+
scale: scale$2,
|
|
1600
|
+
subtract: subtract,
|
|
1601
|
+
toArray: toArray,
|
|
1579
1602
|
transformMatrix: transformMatrix$1,
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
isEqual: isEqual$2,
|
|
1583
|
-
max: max,
|
|
1584
|
-
min: min,
|
|
1585
|
-
negate: negate,
|
|
1586
|
-
lerp: lerp,
|
|
1587
|
-
transformNdcToWorldSpace: transformNdcToWorldSpace
|
|
1603
|
+
transformNdcToWorldSpace: transformNdcToWorldSpace,
|
|
1604
|
+
up: up
|
|
1588
1605
|
});
|
|
1589
1606
|
|
|
1590
1607
|
/**
|
|
@@ -1649,14 +1666,14 @@ function isValid(boundingBox) {
|
|
|
1649
1666
|
|
|
1650
1667
|
var boundingBox = /*#__PURE__*/Object.freeze({
|
|
1651
1668
|
__proto__: null,
|
|
1652
|
-
create: create$9,
|
|
1653
|
-
fromVectors: fromVectors,
|
|
1654
1669
|
center: center$3,
|
|
1670
|
+
create: create$9,
|
|
1655
1671
|
diagonal: diagonal,
|
|
1656
1672
|
epsilon: epsilon,
|
|
1657
|
-
|
|
1673
|
+
fromVectors: fromVectors,
|
|
1674
|
+
isValid: isValid,
|
|
1658
1675
|
lengths: lengths,
|
|
1659
|
-
|
|
1676
|
+
union: union
|
|
1660
1677
|
});
|
|
1661
1678
|
|
|
1662
1679
|
/**
|
|
@@ -1870,26 +1887,26 @@ function fromJson$1(json) {
|
|
|
1870
1887
|
|
|
1871
1888
|
var rectangle = /*#__PURE__*/Object.freeze({
|
|
1872
1889
|
__proto__: null,
|
|
1890
|
+
area: area$1,
|
|
1891
|
+
bottomRight: bottomRight,
|
|
1892
|
+
center: center$2,
|
|
1893
|
+
containFit: containFit$1,
|
|
1894
|
+
containsPoints: containsPoints,
|
|
1873
1895
|
create: create$7,
|
|
1896
|
+
cropFit: cropFit$1,
|
|
1874
1897
|
fromDimensions: fromDimensions,
|
|
1898
|
+
fromJson: fromJson$1,
|
|
1875
1899
|
fromPointAndDimensions: fromPointAndDimensions,
|
|
1876
1900
|
fromPoints: fromPoints,
|
|
1877
|
-
containFit: containFit$1,
|
|
1878
|
-
cropFit: cropFit$1,
|
|
1879
|
-
scaleFit: scaleFit$1,
|
|
1880
|
-
scale: scale$1,
|
|
1881
1901
|
isEqual: isEqual$1,
|
|
1882
|
-
offset: offset,
|
|
1883
|
-
area: area$1,
|
|
1884
|
-
center: center$2,
|
|
1885
|
-
topLeft: topLeft,
|
|
1886
|
-
bottomRight: bottomRight,
|
|
1887
|
-
isPortrait: isPortrait,
|
|
1888
1902
|
isLandscape: isLandscape,
|
|
1903
|
+
isPortrait: isPortrait,
|
|
1889
1904
|
isSquare: isSquare,
|
|
1905
|
+
offset: offset,
|
|
1890
1906
|
pad: pad,
|
|
1891
|
-
|
|
1892
|
-
|
|
1907
|
+
scale: scale$1,
|
|
1908
|
+
scaleFit: scaleFit$1,
|
|
1909
|
+
topLeft: topLeft
|
|
1893
1910
|
});
|
|
1894
1911
|
|
|
1895
1912
|
/**
|
|
@@ -2033,22 +2050,22 @@ function toRectangle(dimensions, position) {
|
|
|
2033
2050
|
|
|
2034
2051
|
var dimensions = /*#__PURE__*/Object.freeze({
|
|
2035
2052
|
__proto__: null,
|
|
2053
|
+
area: area,
|
|
2054
|
+
aspectRatio: aspectRatio,
|
|
2055
|
+
center: center$1,
|
|
2056
|
+
containFit: containFit,
|
|
2036
2057
|
create: create$6,
|
|
2037
|
-
|
|
2058
|
+
cropFit: cropFit,
|
|
2059
|
+
fitToRatio: fitToRatio,
|
|
2060
|
+
floor: floor,
|
|
2038
2061
|
isEqual: isEqual,
|
|
2039
|
-
scale: scale,
|
|
2040
2062
|
proportionalScale: proportionalScale,
|
|
2041
|
-
trim: trim,
|
|
2042
|
-
containFit: containFit,
|
|
2043
|
-
cropFit: cropFit,
|
|
2044
|
-
scaleFit: scaleFit,
|
|
2045
2063
|
round: round,
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
toRectangle: toRectangle
|
|
2064
|
+
scale: scale,
|
|
2065
|
+
scaleFit: scaleFit,
|
|
2066
|
+
square: square,
|
|
2067
|
+
toRectangle: toRectangle,
|
|
2068
|
+
trim: trim
|
|
2052
2069
|
});
|
|
2053
2070
|
|
|
2054
2071
|
/**
|
|
@@ -2080,8 +2097,8 @@ function center(line) {
|
|
|
2080
2097
|
* @returns A transformed line.
|
|
2081
2098
|
*/
|
|
2082
2099
|
function transformMatrix(line, matrix) {
|
|
2083
|
-
var start =
|
|
2084
|
-
var end =
|
|
2100
|
+
var start = multiplyByTransformMatrixColumnMajor(line.start, matrix);
|
|
2101
|
+
var end = multiplyByTransformMatrixColumnMajor(line.end, matrix);
|
|
2085
2102
|
return { start: start, end: end };
|
|
2086
2103
|
}
|
|
2087
2104
|
/**
|
|
@@ -2106,12 +2123,12 @@ function direction(line) {
|
|
|
2106
2123
|
|
|
2107
2124
|
var line3 = /*#__PURE__*/Object.freeze({
|
|
2108
2125
|
__proto__: null,
|
|
2109
|
-
create: create$5,
|
|
2110
2126
|
center: center,
|
|
2111
|
-
|
|
2127
|
+
create: create$5,
|
|
2128
|
+
direction: direction,
|
|
2112
2129
|
distance: distance,
|
|
2113
2130
|
distanceSquared: distanceSquared,
|
|
2114
|
-
|
|
2131
|
+
transformMatrix: transformMatrix
|
|
2115
2132
|
});
|
|
2116
2133
|
|
|
2117
2134
|
/**
|
|
@@ -2180,11 +2197,11 @@ var matrix = /*#__PURE__*/Object.freeze({
|
|
|
2180
2197
|
__proto__: null,
|
|
2181
2198
|
create: create$4,
|
|
2182
2199
|
identity: identity,
|
|
2183
|
-
translation: translation,
|
|
2184
|
-
rotation: rotation,
|
|
2185
2200
|
rotate: rotate,
|
|
2201
|
+
rotation: rotation,
|
|
2202
|
+
transformPoint: transformPoint,
|
|
2186
2203
|
translate: translate,
|
|
2187
|
-
|
|
2204
|
+
translation: translation
|
|
2188
2205
|
});
|
|
2189
2206
|
|
|
2190
2207
|
function create$3() {
|
|
@@ -2309,8 +2326,8 @@ function projectPoint(plane, point) {
|
|
|
2309
2326
|
var plane = /*#__PURE__*/Object.freeze({
|
|
2310
2327
|
__proto__: null,
|
|
2311
2328
|
create: create$2,
|
|
2312
|
-
fromNormalAndCoplanarPoint: fromNormalAndCoplanarPoint,
|
|
2313
2329
|
distanceToPoint: distanceToPoint,
|
|
2330
|
+
fromNormalAndCoplanarPoint: fromNormalAndCoplanarPoint,
|
|
2314
2331
|
intersectLine: intersectLine,
|
|
2315
2332
|
projectPoint: projectPoint
|
|
2316
2333
|
});
|
|
@@ -2377,8 +2394,8 @@ function intersectPlane(ray, plane) {
|
|
|
2377
2394
|
|
|
2378
2395
|
var ray = /*#__PURE__*/Object.freeze({
|
|
2379
2396
|
__proto__: null,
|
|
2380
|
-
create: create$1,
|
|
2381
2397
|
at: at,
|
|
2398
|
+
create: create$1,
|
|
2382
2399
|
distanceToPlane: distanceToPlane,
|
|
2383
2400
|
intersectPlane: intersectPlane
|
|
2384
2401
|
});
|