@math.gl/core 4.0.0-alpha.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gl-matrix/mat3.d.ts +36 -44
- package/dist/gl-matrix/mat3.d.ts.map +1 -1
- package/dist/gl-matrix/mat3.js.map +1 -1
- package/dist/gl-matrix/mat4.d.ts +64 -91
- package/dist/gl-matrix/mat4.d.ts.map +1 -1
- package/dist/gl-matrix/mat4.js.map +1 -1
- package/dist/gl-matrix/quat.d.ts +1 -1
- package/dist/gl-matrix/quat.d.ts.map +1 -1
- package/dist/gl-matrix/vec2.d.ts +169 -179
- package/dist/gl-matrix/vec2.d.ts.map +1 -1
- package/dist/gl-matrix/vec2.js.map +1 -1
- package/dist/gl-matrix/vec3.d.ts +74 -84
- package/dist/gl-matrix/vec3.d.ts.map +1 -1
- package/dist/gl-matrix/vec3.js.map +1 -1
- package/dist/gl-matrix/vec4.d.ts +66 -76
- package/dist/gl-matrix/vec4.d.ts.map +1 -1
- package/dist/gl-matrix/vec4.js.map +1 -1
- package/dist/index.cjs +2215 -211
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/gl-matrix/{vec2.js → vec2.ts} +100 -99
- package/src/index.ts +13 -0
- package/src/lib/gl-matrix.d.ts +2 -0
- /package/src/gl-matrix/{mat3.js → mat3.ts} +0 -0
- /package/src/gl-matrix/{mat4.js → mat4.ts} +0 -0
- /package/src/gl-matrix/{vec3.js → vec3.ts} +0 -0
- /package/src/gl-matrix/{vec4.js → vec4.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -61,11 +61,17 @@ __export(src_exports, {
|
|
|
61
61
|
formatValue: () => formatValue,
|
|
62
62
|
isArray: () => isArray,
|
|
63
63
|
lerp: () => lerp,
|
|
64
|
+
mat3: () => mat3_exports,
|
|
65
|
+
mat4: () => mat4_exports,
|
|
66
|
+
quat: () => quat_exports,
|
|
64
67
|
radians: () => radians,
|
|
65
68
|
sin: () => sin,
|
|
66
69
|
tan: () => tan,
|
|
67
70
|
toDegrees: () => toDegrees,
|
|
68
71
|
toRadians: () => toRadians,
|
|
72
|
+
vec2: () => vec2_exports,
|
|
73
|
+
vec3: () => vec3_exports,
|
|
74
|
+
vec4: () => vec4_exports,
|
|
69
75
|
withEpsilon: () => withEpsilon
|
|
70
76
|
});
|
|
71
77
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -111,25 +117,25 @@ function degrees(radians2, result) {
|
|
|
111
117
|
return map(radians2, (radians3) => radians3 * RADIANS_TO_DEGREES, result);
|
|
112
118
|
}
|
|
113
119
|
function sin(radians2, result) {
|
|
114
|
-
return map(radians2, (
|
|
120
|
+
return map(radians2, (angle3) => Math.sin(angle3), result);
|
|
115
121
|
}
|
|
116
122
|
function cos(radians2, result) {
|
|
117
|
-
return map(radians2, (
|
|
123
|
+
return map(radians2, (angle3) => Math.cos(angle3), result);
|
|
118
124
|
}
|
|
119
125
|
function tan(radians2, result) {
|
|
120
|
-
return map(radians2, (
|
|
126
|
+
return map(radians2, (angle3) => Math.tan(angle3), result);
|
|
121
127
|
}
|
|
122
128
|
function asin(radians2, result) {
|
|
123
|
-
return map(radians2, (
|
|
129
|
+
return map(radians2, (angle3) => Math.asin(angle3), result);
|
|
124
130
|
}
|
|
125
131
|
function acos(radians2, result) {
|
|
126
|
-
return map(radians2, (
|
|
132
|
+
return map(radians2, (angle3) => Math.acos(angle3), result);
|
|
127
133
|
}
|
|
128
134
|
function atan(radians2, result) {
|
|
129
|
-
return map(radians2, (
|
|
135
|
+
return map(radians2, (angle3) => Math.atan(angle3), result);
|
|
130
136
|
}
|
|
131
|
-
function clamp(value,
|
|
132
|
-
return map(value, (value2) => Math.max(
|
|
137
|
+
function clamp(value, min4, max4) {
|
|
138
|
+
return map(value, (value2) => Math.max(min4, Math.min(max4, value2)));
|
|
133
139
|
}
|
|
134
140
|
function lerp(a, b, t) {
|
|
135
141
|
if (isArray(a)) {
|
|
@@ -344,14 +350,14 @@ var MathArray = class extends Array {
|
|
|
344
350
|
}
|
|
345
351
|
return this.check();
|
|
346
352
|
}
|
|
347
|
-
scale(
|
|
348
|
-
if (typeof
|
|
353
|
+
scale(scale7) {
|
|
354
|
+
if (typeof scale7 === "number") {
|
|
349
355
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
350
|
-
this[i] *=
|
|
356
|
+
this[i] *= scale7;
|
|
351
357
|
}
|
|
352
358
|
} else {
|
|
353
|
-
for (let i = 0; i < this.ELEMENTS && i <
|
|
354
|
-
this[i] *=
|
|
359
|
+
for (let i = 0; i < this.ELEMENTS && i < scale7.length; ++i) {
|
|
360
|
+
this[i] *= scale7[i];
|
|
355
361
|
}
|
|
356
362
|
}
|
|
357
363
|
return this.check();
|
|
@@ -402,9 +408,9 @@ var MathArray = class extends Array {
|
|
|
402
408
|
divideScalar(a) {
|
|
403
409
|
return this.multiplyByScalar(1 / a);
|
|
404
410
|
}
|
|
405
|
-
clampScalar(
|
|
411
|
+
clampScalar(min4, max4) {
|
|
406
412
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
407
|
-
this[i] = Math.min(Math.max(this[i],
|
|
413
|
+
this[i] = Math.min(Math.max(this[i], min4), max4);
|
|
408
414
|
}
|
|
409
415
|
return this.check();
|
|
410
416
|
}
|
|
@@ -414,8 +420,8 @@ var MathArray = class extends Array {
|
|
|
414
420
|
};
|
|
415
421
|
|
|
416
422
|
// src/lib/validators.ts
|
|
417
|
-
function validateVector(v,
|
|
418
|
-
if (v.length !==
|
|
423
|
+
function validateVector(v, length5) {
|
|
424
|
+
if (v.length !== length5) {
|
|
419
425
|
return false;
|
|
420
426
|
}
|
|
421
427
|
for (let i = 0; i < v.length; ++i) {
|
|
@@ -431,8 +437,8 @@ function checkNumber(value) {
|
|
|
431
437
|
}
|
|
432
438
|
return value;
|
|
433
439
|
}
|
|
434
|
-
function checkVector(v,
|
|
435
|
-
if (config.debug && !validateVector(v,
|
|
440
|
+
function checkVector(v, length5, callerName = "") {
|
|
441
|
+
if (config.debug && !validateVector(v, length5)) {
|
|
436
442
|
throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
|
|
437
443
|
}
|
|
438
444
|
return v;
|
|
@@ -466,11 +472,11 @@ var Vector = class extends MathArray {
|
|
|
466
472
|
return this.len();
|
|
467
473
|
}
|
|
468
474
|
lengthSquared() {
|
|
469
|
-
let
|
|
475
|
+
let length5 = 0;
|
|
470
476
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
471
|
-
|
|
477
|
+
length5 += this[i] * this[i];
|
|
472
478
|
}
|
|
473
|
-
return
|
|
479
|
+
return length5;
|
|
474
480
|
}
|
|
475
481
|
magnitudeSquared() {
|
|
476
482
|
return this.lengthSquared();
|
|
@@ -479,12 +485,12 @@ var Vector = class extends MathArray {
|
|
|
479
485
|
return Math.sqrt(this.distanceSquared(mathArray));
|
|
480
486
|
}
|
|
481
487
|
distanceSquared(mathArray) {
|
|
482
|
-
let
|
|
488
|
+
let length5 = 0;
|
|
483
489
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
484
|
-
const
|
|
485
|
-
|
|
490
|
+
const dist4 = this[i] - mathArray[i];
|
|
491
|
+
length5 += dist4 * dist4;
|
|
486
492
|
}
|
|
487
|
-
return checkNumber(
|
|
493
|
+
return checkNumber(length5);
|
|
488
494
|
}
|
|
489
495
|
dot(mathArray) {
|
|
490
496
|
let product = 0;
|
|
@@ -494,10 +500,10 @@ var Vector = class extends MathArray {
|
|
|
494
500
|
return checkNumber(product);
|
|
495
501
|
}
|
|
496
502
|
normalize() {
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
503
|
+
const length5 = this.magnitude();
|
|
504
|
+
if (length5 !== 0) {
|
|
499
505
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
500
|
-
this[i] /=
|
|
506
|
+
this[i] /= length5;
|
|
501
507
|
}
|
|
502
508
|
}
|
|
503
509
|
return this.check();
|
|
@@ -550,12 +556,68 @@ var Vector = class extends MathArray {
|
|
|
550
556
|
}
|
|
551
557
|
};
|
|
552
558
|
|
|
559
|
+
// src/gl-matrix/vec2.ts
|
|
560
|
+
var vec2_exports = {};
|
|
561
|
+
__export(vec2_exports, {
|
|
562
|
+
add: () => add,
|
|
563
|
+
angle: () => angle,
|
|
564
|
+
ceil: () => ceil,
|
|
565
|
+
clone: () => clone2,
|
|
566
|
+
copy: () => copy,
|
|
567
|
+
create: () => create,
|
|
568
|
+
cross: () => cross,
|
|
569
|
+
dist: () => dist,
|
|
570
|
+
distance: () => distance,
|
|
571
|
+
div: () => div,
|
|
572
|
+
divide: () => divide,
|
|
573
|
+
dot: () => dot,
|
|
574
|
+
equals: () => equals2,
|
|
575
|
+
exactEquals: () => exactEquals2,
|
|
576
|
+
floor: () => floor,
|
|
577
|
+
forEach: () => forEach,
|
|
578
|
+
fromValues: () => fromValues,
|
|
579
|
+
inverse: () => inverse,
|
|
580
|
+
len: () => len,
|
|
581
|
+
length: () => length,
|
|
582
|
+
lerp: () => lerp2,
|
|
583
|
+
max: () => max,
|
|
584
|
+
min: () => min,
|
|
585
|
+
mul: () => mul,
|
|
586
|
+
multiply: () => multiply,
|
|
587
|
+
negate: () => negate,
|
|
588
|
+
normalize: () => normalize,
|
|
589
|
+
random: () => random,
|
|
590
|
+
rotate: () => rotate,
|
|
591
|
+
round: () => round3,
|
|
592
|
+
scale: () => scale,
|
|
593
|
+
scaleAndAdd: () => scaleAndAdd,
|
|
594
|
+
set: () => set,
|
|
595
|
+
sqrDist: () => sqrDist,
|
|
596
|
+
sqrLen: () => sqrLen,
|
|
597
|
+
squaredDistance: () => squaredDistance,
|
|
598
|
+
squaredLength: () => squaredLength,
|
|
599
|
+
str: () => str,
|
|
600
|
+
sub: () => sub,
|
|
601
|
+
subtract: () => subtract,
|
|
602
|
+
transformMat2: () => transformMat2,
|
|
603
|
+
transformMat2d: () => transformMat2d,
|
|
604
|
+
transformMat3: () => transformMat3,
|
|
605
|
+
transformMat4: () => transformMat4,
|
|
606
|
+
zero: () => zero
|
|
607
|
+
});
|
|
608
|
+
|
|
553
609
|
// src/gl-matrix/common.js
|
|
554
610
|
var EPSILON = 1e-6;
|
|
555
611
|
var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
|
|
612
|
+
var RANDOM = Math.random;
|
|
613
|
+
function round2(a) {
|
|
614
|
+
if (a >= 0)
|
|
615
|
+
return Math.round(a);
|
|
616
|
+
return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
|
|
617
|
+
}
|
|
556
618
|
var degree = Math.PI / 180;
|
|
557
619
|
|
|
558
|
-
// src/gl-matrix/vec2.
|
|
620
|
+
// src/gl-matrix/vec2.ts
|
|
559
621
|
function create() {
|
|
560
622
|
const out = new ARRAY_TYPE(2);
|
|
561
623
|
if (ARRAY_TYPE != Float32Array) {
|
|
@@ -564,6 +626,147 @@ function create() {
|
|
|
564
626
|
}
|
|
565
627
|
return out;
|
|
566
628
|
}
|
|
629
|
+
function clone2(a) {
|
|
630
|
+
const out = new ARRAY_TYPE(2);
|
|
631
|
+
out[0] = a[0];
|
|
632
|
+
out[1] = a[1];
|
|
633
|
+
return out;
|
|
634
|
+
}
|
|
635
|
+
function fromValues(x, y) {
|
|
636
|
+
const out = new ARRAY_TYPE(2);
|
|
637
|
+
out[0] = x;
|
|
638
|
+
out[1] = y;
|
|
639
|
+
return out;
|
|
640
|
+
}
|
|
641
|
+
function copy(out, a) {
|
|
642
|
+
out[0] = a[0];
|
|
643
|
+
out[1] = a[1];
|
|
644
|
+
return out;
|
|
645
|
+
}
|
|
646
|
+
function set(out, x, y) {
|
|
647
|
+
out[0] = x;
|
|
648
|
+
out[1] = y;
|
|
649
|
+
return out;
|
|
650
|
+
}
|
|
651
|
+
function add(out, a, b) {
|
|
652
|
+
out[0] = a[0] + b[0];
|
|
653
|
+
out[1] = a[1] + b[1];
|
|
654
|
+
return out;
|
|
655
|
+
}
|
|
656
|
+
function subtract(out, a, b) {
|
|
657
|
+
out[0] = a[0] - b[0];
|
|
658
|
+
out[1] = a[1] - b[1];
|
|
659
|
+
return out;
|
|
660
|
+
}
|
|
661
|
+
function multiply(out, a, b) {
|
|
662
|
+
out[0] = a[0] * b[0];
|
|
663
|
+
out[1] = a[1] * b[1];
|
|
664
|
+
return out;
|
|
665
|
+
}
|
|
666
|
+
function divide(out, a, b) {
|
|
667
|
+
out[0] = a[0] / b[0];
|
|
668
|
+
out[1] = a[1] / b[1];
|
|
669
|
+
return out;
|
|
670
|
+
}
|
|
671
|
+
function ceil(out, a) {
|
|
672
|
+
out[0] = Math.ceil(a[0]);
|
|
673
|
+
out[1] = Math.ceil(a[1]);
|
|
674
|
+
return out;
|
|
675
|
+
}
|
|
676
|
+
function floor(out, a) {
|
|
677
|
+
out[0] = Math.floor(a[0]);
|
|
678
|
+
out[1] = Math.floor(a[1]);
|
|
679
|
+
return out;
|
|
680
|
+
}
|
|
681
|
+
function min(out, a, b) {
|
|
682
|
+
out[0] = Math.min(a[0], b[0]);
|
|
683
|
+
out[1] = Math.min(a[1], b[1]);
|
|
684
|
+
return out;
|
|
685
|
+
}
|
|
686
|
+
function max(out, a, b) {
|
|
687
|
+
out[0] = Math.max(a[0], b[0]);
|
|
688
|
+
out[1] = Math.max(a[1], b[1]);
|
|
689
|
+
return out;
|
|
690
|
+
}
|
|
691
|
+
function round3(out, a) {
|
|
692
|
+
out[0] = round2(a[0]);
|
|
693
|
+
out[1] = round2(a[1]);
|
|
694
|
+
return out;
|
|
695
|
+
}
|
|
696
|
+
function scale(out, a, b) {
|
|
697
|
+
out[0] = a[0] * b;
|
|
698
|
+
out[1] = a[1] * b;
|
|
699
|
+
return out;
|
|
700
|
+
}
|
|
701
|
+
function scaleAndAdd(out, a, b, scale7) {
|
|
702
|
+
out[0] = a[0] + b[0] * scale7;
|
|
703
|
+
out[1] = a[1] + b[1] * scale7;
|
|
704
|
+
return out;
|
|
705
|
+
}
|
|
706
|
+
function distance(a, b) {
|
|
707
|
+
const x = b[0] - a[0];
|
|
708
|
+
const y = b[1] - a[1];
|
|
709
|
+
return Math.sqrt(x * x + y * y);
|
|
710
|
+
}
|
|
711
|
+
function squaredDistance(a, b) {
|
|
712
|
+
const x = b[0] - a[0];
|
|
713
|
+
const y = b[1] - a[1];
|
|
714
|
+
return x * x + y * y;
|
|
715
|
+
}
|
|
716
|
+
function length(a) {
|
|
717
|
+
const x = a[0];
|
|
718
|
+
const y = a[1];
|
|
719
|
+
return Math.sqrt(x * x + y * y);
|
|
720
|
+
}
|
|
721
|
+
function squaredLength(a) {
|
|
722
|
+
const x = a[0];
|
|
723
|
+
const y = a[1];
|
|
724
|
+
return x * x + y * y;
|
|
725
|
+
}
|
|
726
|
+
function negate(out, a) {
|
|
727
|
+
out[0] = -a[0];
|
|
728
|
+
out[1] = -a[1];
|
|
729
|
+
return out;
|
|
730
|
+
}
|
|
731
|
+
function inverse(out, a) {
|
|
732
|
+
out[0] = 1 / a[0];
|
|
733
|
+
out[1] = 1 / a[1];
|
|
734
|
+
return out;
|
|
735
|
+
}
|
|
736
|
+
function normalize(out, a) {
|
|
737
|
+
const x = a[0];
|
|
738
|
+
const y = a[1];
|
|
739
|
+
let len5 = x * x + y * y;
|
|
740
|
+
if (len5 > 0) {
|
|
741
|
+
len5 = 1 / Math.sqrt(len5);
|
|
742
|
+
}
|
|
743
|
+
out[0] = a[0] * len5;
|
|
744
|
+
out[1] = a[1] * len5;
|
|
745
|
+
return out;
|
|
746
|
+
}
|
|
747
|
+
function dot(a, b) {
|
|
748
|
+
return a[0] * b[0] + a[1] * b[1];
|
|
749
|
+
}
|
|
750
|
+
function cross(out, a, b) {
|
|
751
|
+
const z = a[0] * b[1] - a[1] * b[0];
|
|
752
|
+
out[0] = out[1] = 0;
|
|
753
|
+
out[2] = z;
|
|
754
|
+
return out;
|
|
755
|
+
}
|
|
756
|
+
function lerp2(out, a, b, t) {
|
|
757
|
+
const ax = a[0];
|
|
758
|
+
const ay = a[1];
|
|
759
|
+
out[0] = ax + t * (b[0] - ax);
|
|
760
|
+
out[1] = ay + t * (b[1] - ay);
|
|
761
|
+
return out;
|
|
762
|
+
}
|
|
763
|
+
function random(out, scale7) {
|
|
764
|
+
scale7 = scale7 === void 0 ? 1 : scale7;
|
|
765
|
+
const r = RANDOM() * 2 * Math.PI;
|
|
766
|
+
out[0] = Math.cos(r) * scale7;
|
|
767
|
+
out[1] = Math.sin(r) * scale7;
|
|
768
|
+
return out;
|
|
769
|
+
}
|
|
567
770
|
function transformMat2(out, a, m) {
|
|
568
771
|
const x = a[0];
|
|
569
772
|
const y = a[1];
|
|
@@ -592,6 +795,49 @@ function transformMat4(out, a, m) {
|
|
|
592
795
|
out[1] = m[1] * x + m[5] * y + m[13];
|
|
593
796
|
return out;
|
|
594
797
|
}
|
|
798
|
+
function rotate(out, a, b, rad) {
|
|
799
|
+
const p0 = a[0] - b[0];
|
|
800
|
+
const p1 = a[1] - b[1];
|
|
801
|
+
const sinC = Math.sin(rad);
|
|
802
|
+
const cosC = Math.cos(rad);
|
|
803
|
+
out[0] = p0 * cosC - p1 * sinC + b[0];
|
|
804
|
+
out[1] = p0 * sinC + p1 * cosC + b[1];
|
|
805
|
+
return out;
|
|
806
|
+
}
|
|
807
|
+
function angle(a, b) {
|
|
808
|
+
const x1 = a[0];
|
|
809
|
+
const y1 = a[1];
|
|
810
|
+
const x2 = b[0];
|
|
811
|
+
const y2 = b[1];
|
|
812
|
+
const mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));
|
|
813
|
+
const cosine = mag && (x1 * x2 + y1 * y2) / mag;
|
|
814
|
+
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
815
|
+
}
|
|
816
|
+
function zero(out) {
|
|
817
|
+
out[0] = 0;
|
|
818
|
+
out[1] = 0;
|
|
819
|
+
return out;
|
|
820
|
+
}
|
|
821
|
+
function str(a) {
|
|
822
|
+
return `vec2(${a[0]}, ${a[1]})`;
|
|
823
|
+
}
|
|
824
|
+
function exactEquals2(a, b) {
|
|
825
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
826
|
+
}
|
|
827
|
+
function equals2(a, b) {
|
|
828
|
+
const a0 = a[0];
|
|
829
|
+
const a1 = a[1];
|
|
830
|
+
const b0 = b[0];
|
|
831
|
+
const b1 = b[1];
|
|
832
|
+
return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1));
|
|
833
|
+
}
|
|
834
|
+
var len = length;
|
|
835
|
+
var sub = subtract;
|
|
836
|
+
var mul = multiply;
|
|
837
|
+
var div = divide;
|
|
838
|
+
var dist = distance;
|
|
839
|
+
var sqrDist = squaredDistance;
|
|
840
|
+
var sqrLen = squaredLength;
|
|
595
841
|
var forEach = function() {
|
|
596
842
|
const vec = create();
|
|
597
843
|
return function(a, stride, offset, count, fn, arg) {
|
|
@@ -739,7 +985,59 @@ var Vector2 = class extends Vector {
|
|
|
739
985
|
}
|
|
740
986
|
};
|
|
741
987
|
|
|
742
|
-
// src/gl-matrix/vec3.
|
|
988
|
+
// src/gl-matrix/vec3.ts
|
|
989
|
+
var vec3_exports = {};
|
|
990
|
+
__export(vec3_exports, {
|
|
991
|
+
add: () => add2,
|
|
992
|
+
angle: () => angle2,
|
|
993
|
+
bezier: () => bezier,
|
|
994
|
+
ceil: () => ceil2,
|
|
995
|
+
clone: () => clone3,
|
|
996
|
+
copy: () => copy2,
|
|
997
|
+
create: () => create2,
|
|
998
|
+
cross: () => cross2,
|
|
999
|
+
dist: () => dist2,
|
|
1000
|
+
distance: () => distance2,
|
|
1001
|
+
div: () => div2,
|
|
1002
|
+
divide: () => divide2,
|
|
1003
|
+
dot: () => dot2,
|
|
1004
|
+
equals: () => equals3,
|
|
1005
|
+
exactEquals: () => exactEquals3,
|
|
1006
|
+
floor: () => floor2,
|
|
1007
|
+
forEach: () => forEach2,
|
|
1008
|
+
fromValues: () => fromValues2,
|
|
1009
|
+
hermite: () => hermite,
|
|
1010
|
+
inverse: () => inverse2,
|
|
1011
|
+
len: () => len2,
|
|
1012
|
+
length: () => length2,
|
|
1013
|
+
lerp: () => lerp3,
|
|
1014
|
+
max: () => max2,
|
|
1015
|
+
min: () => min2,
|
|
1016
|
+
mul: () => mul2,
|
|
1017
|
+
multiply: () => multiply2,
|
|
1018
|
+
negate: () => negate2,
|
|
1019
|
+
normalize: () => normalize2,
|
|
1020
|
+
random: () => random2,
|
|
1021
|
+
rotateX: () => rotateX,
|
|
1022
|
+
rotateY: () => rotateY,
|
|
1023
|
+
rotateZ: () => rotateZ,
|
|
1024
|
+
round: () => round4,
|
|
1025
|
+
scale: () => scale2,
|
|
1026
|
+
scaleAndAdd: () => scaleAndAdd2,
|
|
1027
|
+
set: () => set2,
|
|
1028
|
+
slerp: () => slerp,
|
|
1029
|
+
sqrDist: () => sqrDist2,
|
|
1030
|
+
sqrLen: () => sqrLen2,
|
|
1031
|
+
squaredDistance: () => squaredDistance2,
|
|
1032
|
+
squaredLength: () => squaredLength2,
|
|
1033
|
+
str: () => str2,
|
|
1034
|
+
sub: () => sub2,
|
|
1035
|
+
subtract: () => subtract2,
|
|
1036
|
+
transformMat3: () => transformMat32,
|
|
1037
|
+
transformMat4: () => transformMat42,
|
|
1038
|
+
transformQuat: () => transformQuat,
|
|
1039
|
+
zero: () => zero2
|
|
1040
|
+
});
|
|
743
1041
|
function create2() {
|
|
744
1042
|
const out = new ARRAY_TYPE(3);
|
|
745
1043
|
if (ARRAY_TYPE != Float32Array) {
|
|
@@ -749,36 +1047,151 @@ function create2() {
|
|
|
749
1047
|
}
|
|
750
1048
|
return out;
|
|
751
1049
|
}
|
|
752
|
-
function
|
|
1050
|
+
function clone3(a) {
|
|
1051
|
+
const out = new ARRAY_TYPE(3);
|
|
1052
|
+
out[0] = a[0];
|
|
1053
|
+
out[1] = a[1];
|
|
1054
|
+
out[2] = a[2];
|
|
1055
|
+
return out;
|
|
1056
|
+
}
|
|
1057
|
+
function length2(a) {
|
|
753
1058
|
const x = a[0];
|
|
754
1059
|
const y = a[1];
|
|
755
1060
|
const z = a[2];
|
|
756
1061
|
return Math.sqrt(x * x + y * y + z * z);
|
|
757
1062
|
}
|
|
758
|
-
function
|
|
1063
|
+
function fromValues2(x, y, z) {
|
|
759
1064
|
const out = new ARRAY_TYPE(3);
|
|
760
1065
|
out[0] = x;
|
|
761
1066
|
out[1] = y;
|
|
762
1067
|
out[2] = z;
|
|
763
1068
|
return out;
|
|
764
1069
|
}
|
|
765
|
-
function
|
|
1070
|
+
function copy2(out, a) {
|
|
1071
|
+
out[0] = a[0];
|
|
1072
|
+
out[1] = a[1];
|
|
1073
|
+
out[2] = a[2];
|
|
1074
|
+
return out;
|
|
1075
|
+
}
|
|
1076
|
+
function set2(out, x, y, z) {
|
|
1077
|
+
out[0] = x;
|
|
1078
|
+
out[1] = y;
|
|
1079
|
+
out[2] = z;
|
|
1080
|
+
return out;
|
|
1081
|
+
}
|
|
1082
|
+
function add2(out, a, b) {
|
|
1083
|
+
out[0] = a[0] + b[0];
|
|
1084
|
+
out[1] = a[1] + b[1];
|
|
1085
|
+
out[2] = a[2] + b[2];
|
|
1086
|
+
return out;
|
|
1087
|
+
}
|
|
1088
|
+
function subtract2(out, a, b) {
|
|
1089
|
+
out[0] = a[0] - b[0];
|
|
1090
|
+
out[1] = a[1] - b[1];
|
|
1091
|
+
out[2] = a[2] - b[2];
|
|
1092
|
+
return out;
|
|
1093
|
+
}
|
|
1094
|
+
function multiply2(out, a, b) {
|
|
1095
|
+
out[0] = a[0] * b[0];
|
|
1096
|
+
out[1] = a[1] * b[1];
|
|
1097
|
+
out[2] = a[2] * b[2];
|
|
1098
|
+
return out;
|
|
1099
|
+
}
|
|
1100
|
+
function divide2(out, a, b) {
|
|
1101
|
+
out[0] = a[0] / b[0];
|
|
1102
|
+
out[1] = a[1] / b[1];
|
|
1103
|
+
out[2] = a[2] / b[2];
|
|
1104
|
+
return out;
|
|
1105
|
+
}
|
|
1106
|
+
function ceil2(out, a) {
|
|
1107
|
+
out[0] = Math.ceil(a[0]);
|
|
1108
|
+
out[1] = Math.ceil(a[1]);
|
|
1109
|
+
out[2] = Math.ceil(a[2]);
|
|
1110
|
+
return out;
|
|
1111
|
+
}
|
|
1112
|
+
function floor2(out, a) {
|
|
1113
|
+
out[0] = Math.floor(a[0]);
|
|
1114
|
+
out[1] = Math.floor(a[1]);
|
|
1115
|
+
out[2] = Math.floor(a[2]);
|
|
1116
|
+
return out;
|
|
1117
|
+
}
|
|
1118
|
+
function min2(out, a, b) {
|
|
1119
|
+
out[0] = Math.min(a[0], b[0]);
|
|
1120
|
+
out[1] = Math.min(a[1], b[1]);
|
|
1121
|
+
out[2] = Math.min(a[2], b[2]);
|
|
1122
|
+
return out;
|
|
1123
|
+
}
|
|
1124
|
+
function max2(out, a, b) {
|
|
1125
|
+
out[0] = Math.max(a[0], b[0]);
|
|
1126
|
+
out[1] = Math.max(a[1], b[1]);
|
|
1127
|
+
out[2] = Math.max(a[2], b[2]);
|
|
1128
|
+
return out;
|
|
1129
|
+
}
|
|
1130
|
+
function round4(out, a) {
|
|
1131
|
+
out[0] = round2(a[0]);
|
|
1132
|
+
out[1] = round2(a[1]);
|
|
1133
|
+
out[2] = round2(a[2]);
|
|
1134
|
+
return out;
|
|
1135
|
+
}
|
|
1136
|
+
function scale2(out, a, b) {
|
|
1137
|
+
out[0] = a[0] * b;
|
|
1138
|
+
out[1] = a[1] * b;
|
|
1139
|
+
out[2] = a[2] * b;
|
|
1140
|
+
return out;
|
|
1141
|
+
}
|
|
1142
|
+
function scaleAndAdd2(out, a, b, scale7) {
|
|
1143
|
+
out[0] = a[0] + b[0] * scale7;
|
|
1144
|
+
out[1] = a[1] + b[1] * scale7;
|
|
1145
|
+
out[2] = a[2] + b[2] * scale7;
|
|
1146
|
+
return out;
|
|
1147
|
+
}
|
|
1148
|
+
function distance2(a, b) {
|
|
1149
|
+
const x = b[0] - a[0];
|
|
1150
|
+
const y = b[1] - a[1];
|
|
1151
|
+
const z = b[2] - a[2];
|
|
1152
|
+
return Math.sqrt(x * x + y * y + z * z);
|
|
1153
|
+
}
|
|
1154
|
+
function squaredDistance2(a, b) {
|
|
1155
|
+
const x = b[0] - a[0];
|
|
1156
|
+
const y = b[1] - a[1];
|
|
1157
|
+
const z = b[2] - a[2];
|
|
1158
|
+
return x * x + y * y + z * z;
|
|
1159
|
+
}
|
|
1160
|
+
function squaredLength2(a) {
|
|
1161
|
+
const x = a[0];
|
|
1162
|
+
const y = a[1];
|
|
1163
|
+
const z = a[2];
|
|
1164
|
+
return x * x + y * y + z * z;
|
|
1165
|
+
}
|
|
1166
|
+
function negate2(out, a) {
|
|
1167
|
+
out[0] = -a[0];
|
|
1168
|
+
out[1] = -a[1];
|
|
1169
|
+
out[2] = -a[2];
|
|
1170
|
+
return out;
|
|
1171
|
+
}
|
|
1172
|
+
function inverse2(out, a) {
|
|
1173
|
+
out[0] = 1 / a[0];
|
|
1174
|
+
out[1] = 1 / a[1];
|
|
1175
|
+
out[2] = 1 / a[2];
|
|
1176
|
+
return out;
|
|
1177
|
+
}
|
|
1178
|
+
function normalize2(out, a) {
|
|
766
1179
|
const x = a[0];
|
|
767
1180
|
const y = a[1];
|
|
768
1181
|
const z = a[2];
|
|
769
|
-
let
|
|
770
|
-
if (
|
|
771
|
-
|
|
1182
|
+
let len5 = x * x + y * y + z * z;
|
|
1183
|
+
if (len5 > 0) {
|
|
1184
|
+
len5 = 1 / Math.sqrt(len5);
|
|
772
1185
|
}
|
|
773
|
-
out[0] = a[0] *
|
|
774
|
-
out[1] = a[1] *
|
|
775
|
-
out[2] = a[2] *
|
|
1186
|
+
out[0] = a[0] * len5;
|
|
1187
|
+
out[1] = a[1] * len5;
|
|
1188
|
+
out[2] = a[2] * len5;
|
|
776
1189
|
return out;
|
|
777
1190
|
}
|
|
778
|
-
function
|
|
1191
|
+
function dot2(a, b) {
|
|
779
1192
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
780
1193
|
}
|
|
781
|
-
function
|
|
1194
|
+
function cross2(out, a, b) {
|
|
782
1195
|
const ax = a[0];
|
|
783
1196
|
const ay = a[1];
|
|
784
1197
|
const az = a[2];
|
|
@@ -790,6 +1203,59 @@ function cross(out, a, b) {
|
|
|
790
1203
|
out[2] = ax * by - ay * bx;
|
|
791
1204
|
return out;
|
|
792
1205
|
}
|
|
1206
|
+
function lerp3(out, a, b, t) {
|
|
1207
|
+
const ax = a[0];
|
|
1208
|
+
const ay = a[1];
|
|
1209
|
+
const az = a[2];
|
|
1210
|
+
out[0] = ax + t * (b[0] - ax);
|
|
1211
|
+
out[1] = ay + t * (b[1] - ay);
|
|
1212
|
+
out[2] = az + t * (b[2] - az);
|
|
1213
|
+
return out;
|
|
1214
|
+
}
|
|
1215
|
+
function slerp(out, a, b, t) {
|
|
1216
|
+
const angle3 = Math.acos(Math.min(Math.max(dot2(a, b), -1), 1));
|
|
1217
|
+
const sinTotal = Math.sin(angle3);
|
|
1218
|
+
const ratioA = Math.sin((1 - t) * angle3) / sinTotal;
|
|
1219
|
+
const ratioB = Math.sin(t * angle3) / sinTotal;
|
|
1220
|
+
out[0] = ratioA * a[0] + ratioB * b[0];
|
|
1221
|
+
out[1] = ratioA * a[1] + ratioB * b[1];
|
|
1222
|
+
out[2] = ratioA * a[2] + ratioB * b[2];
|
|
1223
|
+
return out;
|
|
1224
|
+
}
|
|
1225
|
+
function hermite(out, a, b, c, d, t) {
|
|
1226
|
+
const factorTimes2 = t * t;
|
|
1227
|
+
const factor1 = factorTimes2 * (2 * t - 3) + 1;
|
|
1228
|
+
const factor2 = factorTimes2 * (t - 2) + t;
|
|
1229
|
+
const factor3 = factorTimes2 * (t - 1);
|
|
1230
|
+
const factor4 = factorTimes2 * (3 - 2 * t);
|
|
1231
|
+
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
|
|
1232
|
+
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
|
|
1233
|
+
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
|
|
1234
|
+
return out;
|
|
1235
|
+
}
|
|
1236
|
+
function bezier(out, a, b, c, d, t) {
|
|
1237
|
+
const inverseFactor = 1 - t;
|
|
1238
|
+
const inverseFactorTimesTwo = inverseFactor * inverseFactor;
|
|
1239
|
+
const factorTimes2 = t * t;
|
|
1240
|
+
const factor1 = inverseFactorTimesTwo * inverseFactor;
|
|
1241
|
+
const factor2 = 3 * t * inverseFactorTimesTwo;
|
|
1242
|
+
const factor3 = 3 * factorTimes2 * inverseFactor;
|
|
1243
|
+
const factor4 = factorTimes2 * t;
|
|
1244
|
+
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
|
|
1245
|
+
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
|
|
1246
|
+
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
|
|
1247
|
+
return out;
|
|
1248
|
+
}
|
|
1249
|
+
function random2(out, scale7) {
|
|
1250
|
+
scale7 = scale7 === void 0 ? 1 : scale7;
|
|
1251
|
+
const r = RANDOM() * 2 * Math.PI;
|
|
1252
|
+
const z = RANDOM() * 2 - 1;
|
|
1253
|
+
const zScale = Math.sqrt(1 - z * z) * scale7;
|
|
1254
|
+
out[0] = Math.cos(r) * zScale;
|
|
1255
|
+
out[1] = Math.sin(r) * zScale;
|
|
1256
|
+
out[2] = z * scale7;
|
|
1257
|
+
return out;
|
|
1258
|
+
}
|
|
793
1259
|
function transformMat42(out, a, m) {
|
|
794
1260
|
const x = a[0];
|
|
795
1261
|
const y = a[1];
|
|
@@ -878,7 +1344,7 @@ function rotateZ(out, a, b, rad) {
|
|
|
878
1344
|
out[2] = r[2] + b[2];
|
|
879
1345
|
return out;
|
|
880
1346
|
}
|
|
881
|
-
function
|
|
1347
|
+
function angle2(a, b) {
|
|
882
1348
|
const ax = a[0];
|
|
883
1349
|
const ay = a[1];
|
|
884
1350
|
const az = a[2];
|
|
@@ -886,10 +1352,37 @@ function angle(a, b) {
|
|
|
886
1352
|
const by = b[1];
|
|
887
1353
|
const bz = b[2];
|
|
888
1354
|
const mag = Math.sqrt((ax * ax + ay * ay + az * az) * (bx * bx + by * by + bz * bz));
|
|
889
|
-
const cosine = mag &&
|
|
1355
|
+
const cosine = mag && dot2(a, b) / mag;
|
|
890
1356
|
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
891
1357
|
}
|
|
892
|
-
|
|
1358
|
+
function zero2(out) {
|
|
1359
|
+
out[0] = 0;
|
|
1360
|
+
out[1] = 0;
|
|
1361
|
+
out[2] = 0;
|
|
1362
|
+
return out;
|
|
1363
|
+
}
|
|
1364
|
+
function str2(a) {
|
|
1365
|
+
return `vec3(${a[0]}, ${a[1]}, ${a[2]})`;
|
|
1366
|
+
}
|
|
1367
|
+
function exactEquals3(a, b) {
|
|
1368
|
+
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
|
1369
|
+
}
|
|
1370
|
+
function equals3(a, b) {
|
|
1371
|
+
const a0 = a[0];
|
|
1372
|
+
const a1 = a[1];
|
|
1373
|
+
const a2 = a[2];
|
|
1374
|
+
const b0 = b[0];
|
|
1375
|
+
const b1 = b[1];
|
|
1376
|
+
const b2 = b[2];
|
|
1377
|
+
return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2));
|
|
1378
|
+
}
|
|
1379
|
+
var sub2 = subtract2;
|
|
1380
|
+
var mul2 = multiply2;
|
|
1381
|
+
var div2 = divide2;
|
|
1382
|
+
var dist2 = distance2;
|
|
1383
|
+
var sqrDist2 = squaredDistance2;
|
|
1384
|
+
var len2 = length2;
|
|
1385
|
+
var sqrLen2 = squaredLength2;
|
|
893
1386
|
var forEach2 = function() {
|
|
894
1387
|
const vec = create2();
|
|
895
1388
|
return function(a, stride, offset, count, fn, arg) {
|
|
@@ -984,10 +1477,10 @@ var Vector3 = class extends Vector {
|
|
|
984
1477
|
this[2] = checkNumber(value);
|
|
985
1478
|
}
|
|
986
1479
|
angle(vector) {
|
|
987
|
-
return
|
|
1480
|
+
return angle2(this, vector);
|
|
988
1481
|
}
|
|
989
1482
|
cross(vector) {
|
|
990
|
-
|
|
1483
|
+
cross2(this, this, vector);
|
|
991
1484
|
return this.check();
|
|
992
1485
|
}
|
|
993
1486
|
rotateX({ radians: radians2, origin = ORIGIN }) {
|
|
@@ -1171,7 +1664,42 @@ var Matrix = class extends MathArray {
|
|
|
1171
1664
|
}
|
|
1172
1665
|
};
|
|
1173
1666
|
|
|
1174
|
-
// src/gl-matrix/mat3.
|
|
1667
|
+
// src/gl-matrix/mat3.ts
|
|
1668
|
+
var mat3_exports = {};
|
|
1669
|
+
__export(mat3_exports, {
|
|
1670
|
+
add: () => add3,
|
|
1671
|
+
adjoint: () => adjoint,
|
|
1672
|
+
clone: () => clone4,
|
|
1673
|
+
copy: () => copy3,
|
|
1674
|
+
create: () => create3,
|
|
1675
|
+
determinant: () => determinant,
|
|
1676
|
+
equals: () => equals4,
|
|
1677
|
+
exactEquals: () => exactEquals4,
|
|
1678
|
+
frob: () => frob,
|
|
1679
|
+
fromMat2d: () => fromMat2d,
|
|
1680
|
+
fromMat4: () => fromMat4,
|
|
1681
|
+
fromQuat: () => fromQuat,
|
|
1682
|
+
fromRotation: () => fromRotation,
|
|
1683
|
+
fromScaling: () => fromScaling,
|
|
1684
|
+
fromTranslation: () => fromTranslation,
|
|
1685
|
+
fromValues: () => fromValues3,
|
|
1686
|
+
identity: () => identity,
|
|
1687
|
+
invert: () => invert,
|
|
1688
|
+
mul: () => mul3,
|
|
1689
|
+
multiply: () => multiply3,
|
|
1690
|
+
multiplyScalar: () => multiplyScalar,
|
|
1691
|
+
multiplyScalarAndAdd: () => multiplyScalarAndAdd,
|
|
1692
|
+
normalFromMat4: () => normalFromMat4,
|
|
1693
|
+
projection: () => projection,
|
|
1694
|
+
rotate: () => rotate2,
|
|
1695
|
+
scale: () => scale3,
|
|
1696
|
+
set: () => set3,
|
|
1697
|
+
str: () => str3,
|
|
1698
|
+
sub: () => sub3,
|
|
1699
|
+
subtract: () => subtract3,
|
|
1700
|
+
translate: () => translate,
|
|
1701
|
+
transpose: () => transpose
|
|
1702
|
+
});
|
|
1175
1703
|
function create3() {
|
|
1176
1704
|
const out = new ARRAY_TYPE(9);
|
|
1177
1705
|
if (ARRAY_TYPE != Float32Array) {
|
|
@@ -1187,6 +1715,80 @@ function create3() {
|
|
|
1187
1715
|
out[8] = 1;
|
|
1188
1716
|
return out;
|
|
1189
1717
|
}
|
|
1718
|
+
function fromMat4(out, a) {
|
|
1719
|
+
out[0] = a[0];
|
|
1720
|
+
out[1] = a[1];
|
|
1721
|
+
out[2] = a[2];
|
|
1722
|
+
out[3] = a[4];
|
|
1723
|
+
out[4] = a[5];
|
|
1724
|
+
out[5] = a[6];
|
|
1725
|
+
out[6] = a[8];
|
|
1726
|
+
out[7] = a[9];
|
|
1727
|
+
out[8] = a[10];
|
|
1728
|
+
return out;
|
|
1729
|
+
}
|
|
1730
|
+
function clone4(a) {
|
|
1731
|
+
const out = new ARRAY_TYPE(9);
|
|
1732
|
+
out[0] = a[0];
|
|
1733
|
+
out[1] = a[1];
|
|
1734
|
+
out[2] = a[2];
|
|
1735
|
+
out[3] = a[3];
|
|
1736
|
+
out[4] = a[4];
|
|
1737
|
+
out[5] = a[5];
|
|
1738
|
+
out[6] = a[6];
|
|
1739
|
+
out[7] = a[7];
|
|
1740
|
+
out[8] = a[8];
|
|
1741
|
+
return out;
|
|
1742
|
+
}
|
|
1743
|
+
function copy3(out, a) {
|
|
1744
|
+
out[0] = a[0];
|
|
1745
|
+
out[1] = a[1];
|
|
1746
|
+
out[2] = a[2];
|
|
1747
|
+
out[3] = a[3];
|
|
1748
|
+
out[4] = a[4];
|
|
1749
|
+
out[5] = a[5];
|
|
1750
|
+
out[6] = a[6];
|
|
1751
|
+
out[7] = a[7];
|
|
1752
|
+
out[8] = a[8];
|
|
1753
|
+
return out;
|
|
1754
|
+
}
|
|
1755
|
+
function fromValues3(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
|
|
1756
|
+
const out = new ARRAY_TYPE(9);
|
|
1757
|
+
out[0] = m00;
|
|
1758
|
+
out[1] = m01;
|
|
1759
|
+
out[2] = m02;
|
|
1760
|
+
out[3] = m10;
|
|
1761
|
+
out[4] = m11;
|
|
1762
|
+
out[5] = m12;
|
|
1763
|
+
out[6] = m20;
|
|
1764
|
+
out[7] = m21;
|
|
1765
|
+
out[8] = m22;
|
|
1766
|
+
return out;
|
|
1767
|
+
}
|
|
1768
|
+
function set3(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
|
|
1769
|
+
out[0] = m00;
|
|
1770
|
+
out[1] = m01;
|
|
1771
|
+
out[2] = m02;
|
|
1772
|
+
out[3] = m10;
|
|
1773
|
+
out[4] = m11;
|
|
1774
|
+
out[5] = m12;
|
|
1775
|
+
out[6] = m20;
|
|
1776
|
+
out[7] = m21;
|
|
1777
|
+
out[8] = m22;
|
|
1778
|
+
return out;
|
|
1779
|
+
}
|
|
1780
|
+
function identity(out) {
|
|
1781
|
+
out[0] = 1;
|
|
1782
|
+
out[1] = 0;
|
|
1783
|
+
out[2] = 0;
|
|
1784
|
+
out[3] = 0;
|
|
1785
|
+
out[4] = 1;
|
|
1786
|
+
out[5] = 0;
|
|
1787
|
+
out[6] = 0;
|
|
1788
|
+
out[7] = 0;
|
|
1789
|
+
out[8] = 1;
|
|
1790
|
+
return out;
|
|
1791
|
+
}
|
|
1190
1792
|
function transpose(out, a) {
|
|
1191
1793
|
if (out === a) {
|
|
1192
1794
|
const a01 = a[1];
|
|
@@ -1240,6 +1842,27 @@ function invert(out, a) {
|
|
|
1240
1842
|
out[8] = (a11 * a00 - a01 * a10) * det;
|
|
1241
1843
|
return out;
|
|
1242
1844
|
}
|
|
1845
|
+
function adjoint(out, a) {
|
|
1846
|
+
const a00 = a[0];
|
|
1847
|
+
const a01 = a[1];
|
|
1848
|
+
const a02 = a[2];
|
|
1849
|
+
const a10 = a[3];
|
|
1850
|
+
const a11 = a[4];
|
|
1851
|
+
const a12 = a[5];
|
|
1852
|
+
const a20 = a[6];
|
|
1853
|
+
const a21 = a[7];
|
|
1854
|
+
const a22 = a[8];
|
|
1855
|
+
out[0] = a11 * a22 - a12 * a21;
|
|
1856
|
+
out[1] = a02 * a21 - a01 * a22;
|
|
1857
|
+
out[2] = a01 * a12 - a02 * a11;
|
|
1858
|
+
out[3] = a12 * a20 - a10 * a22;
|
|
1859
|
+
out[4] = a00 * a22 - a02 * a20;
|
|
1860
|
+
out[5] = a02 * a10 - a00 * a12;
|
|
1861
|
+
out[6] = a10 * a21 - a11 * a20;
|
|
1862
|
+
out[7] = a01 * a20 - a00 * a21;
|
|
1863
|
+
out[8] = a00 * a11 - a01 * a10;
|
|
1864
|
+
return out;
|
|
1865
|
+
}
|
|
1243
1866
|
function determinant(a) {
|
|
1244
1867
|
const a00 = a[0];
|
|
1245
1868
|
const a01 = a[1];
|
|
@@ -1252,7 +1875,7 @@ function determinant(a) {
|
|
|
1252
1875
|
const a22 = a[8];
|
|
1253
1876
|
return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
|
|
1254
1877
|
}
|
|
1255
|
-
function
|
|
1878
|
+
function multiply3(out, a, b) {
|
|
1256
1879
|
const a00 = a[0];
|
|
1257
1880
|
const a01 = a[1];
|
|
1258
1881
|
const a02 = a[2];
|
|
@@ -1305,7 +1928,7 @@ function translate(out, a, v) {
|
|
|
1305
1928
|
out[8] = x * a02 + y * a12 + a22;
|
|
1306
1929
|
return out;
|
|
1307
1930
|
}
|
|
1308
|
-
function
|
|
1931
|
+
function rotate2(out, a, rad) {
|
|
1309
1932
|
const a00 = a[0];
|
|
1310
1933
|
const a01 = a[1];
|
|
1311
1934
|
const a02 = a[2];
|
|
@@ -1328,7 +1951,7 @@ function rotate(out, a, rad) {
|
|
|
1328
1951
|
out[8] = a22;
|
|
1329
1952
|
return out;
|
|
1330
1953
|
}
|
|
1331
|
-
function
|
|
1954
|
+
function scale3(out, a, v) {
|
|
1332
1955
|
const x = v[0];
|
|
1333
1956
|
const y = v[1];
|
|
1334
1957
|
out[0] = x * a[0];
|
|
@@ -1342,24 +1965,74 @@ function scale(out, a, v) {
|
|
|
1342
1965
|
out[8] = a[8];
|
|
1343
1966
|
return out;
|
|
1344
1967
|
}
|
|
1345
|
-
function
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
const
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
out[
|
|
1968
|
+
function fromTranslation(out, v) {
|
|
1969
|
+
out[0] = 1;
|
|
1970
|
+
out[1] = 0;
|
|
1971
|
+
out[2] = 0;
|
|
1972
|
+
out[3] = 0;
|
|
1973
|
+
out[4] = 1;
|
|
1974
|
+
out[5] = 0;
|
|
1975
|
+
out[6] = v[0];
|
|
1976
|
+
out[7] = v[1];
|
|
1977
|
+
out[8] = 1;
|
|
1978
|
+
return out;
|
|
1979
|
+
}
|
|
1980
|
+
function fromRotation(out, rad) {
|
|
1981
|
+
const s = Math.sin(rad);
|
|
1982
|
+
const c = Math.cos(rad);
|
|
1983
|
+
out[0] = c;
|
|
1984
|
+
out[1] = s;
|
|
1985
|
+
out[2] = 0;
|
|
1986
|
+
out[3] = -s;
|
|
1987
|
+
out[4] = c;
|
|
1988
|
+
out[5] = 0;
|
|
1989
|
+
out[6] = 0;
|
|
1990
|
+
out[7] = 0;
|
|
1991
|
+
out[8] = 1;
|
|
1992
|
+
return out;
|
|
1993
|
+
}
|
|
1994
|
+
function fromScaling(out, v) {
|
|
1995
|
+
out[0] = v[0];
|
|
1996
|
+
out[1] = 0;
|
|
1997
|
+
out[2] = 0;
|
|
1998
|
+
out[3] = 0;
|
|
1999
|
+
out[4] = v[1];
|
|
2000
|
+
out[5] = 0;
|
|
2001
|
+
out[6] = 0;
|
|
2002
|
+
out[7] = 0;
|
|
2003
|
+
out[8] = 1;
|
|
2004
|
+
return out;
|
|
2005
|
+
}
|
|
2006
|
+
function fromMat2d(out, a) {
|
|
2007
|
+
out[0] = a[0];
|
|
2008
|
+
out[1] = a[1];
|
|
2009
|
+
out[2] = 0;
|
|
2010
|
+
out[3] = a[2];
|
|
2011
|
+
out[4] = a[3];
|
|
2012
|
+
out[5] = 0;
|
|
2013
|
+
out[6] = a[4];
|
|
2014
|
+
out[7] = a[5];
|
|
2015
|
+
out[8] = 1;
|
|
2016
|
+
return out;
|
|
2017
|
+
}
|
|
2018
|
+
function fromQuat(out, q) {
|
|
2019
|
+
const x = q[0];
|
|
2020
|
+
const y = q[1];
|
|
2021
|
+
const z = q[2];
|
|
2022
|
+
const w = q[3];
|
|
2023
|
+
const x2 = x + x;
|
|
2024
|
+
const y2 = y + y;
|
|
2025
|
+
const z2 = z + z;
|
|
2026
|
+
const xx = x * x2;
|
|
2027
|
+
const yx = y * x2;
|
|
2028
|
+
const yy = y * y2;
|
|
2029
|
+
const zx = z * x2;
|
|
2030
|
+
const zy = z * y2;
|
|
2031
|
+
const zz = z * z2;
|
|
2032
|
+
const wx = w * x2;
|
|
2033
|
+
const wy = w * y2;
|
|
2034
|
+
const wz = w * z2;
|
|
2035
|
+
out[0] = 1 - yy - zz;
|
|
1363
2036
|
out[3] = yx - wz;
|
|
1364
2037
|
out[6] = zx + wy;
|
|
1365
2038
|
out[1] = yx + wz;
|
|
@@ -1370,6 +2043,145 @@ function fromQuat(out, q) {
|
|
|
1370
2043
|
out[8] = 1 - xx - yy;
|
|
1371
2044
|
return out;
|
|
1372
2045
|
}
|
|
2046
|
+
function normalFromMat4(out, a) {
|
|
2047
|
+
const a00 = a[0];
|
|
2048
|
+
const a01 = a[1];
|
|
2049
|
+
const a02 = a[2];
|
|
2050
|
+
const a03 = a[3];
|
|
2051
|
+
const a10 = a[4];
|
|
2052
|
+
const a11 = a[5];
|
|
2053
|
+
const a12 = a[6];
|
|
2054
|
+
const a13 = a[7];
|
|
2055
|
+
const a20 = a[8];
|
|
2056
|
+
const a21 = a[9];
|
|
2057
|
+
const a22 = a[10];
|
|
2058
|
+
const a23 = a[11];
|
|
2059
|
+
const a30 = a[12];
|
|
2060
|
+
const a31 = a[13];
|
|
2061
|
+
const a32 = a[14];
|
|
2062
|
+
const a33 = a[15];
|
|
2063
|
+
const b00 = a00 * a11 - a01 * a10;
|
|
2064
|
+
const b01 = a00 * a12 - a02 * a10;
|
|
2065
|
+
const b02 = a00 * a13 - a03 * a10;
|
|
2066
|
+
const b03 = a01 * a12 - a02 * a11;
|
|
2067
|
+
const b04 = a01 * a13 - a03 * a11;
|
|
2068
|
+
const b05 = a02 * a13 - a03 * a12;
|
|
2069
|
+
const b06 = a20 * a31 - a21 * a30;
|
|
2070
|
+
const b07 = a20 * a32 - a22 * a30;
|
|
2071
|
+
const b08 = a20 * a33 - a23 * a30;
|
|
2072
|
+
const b09 = a21 * a32 - a22 * a31;
|
|
2073
|
+
const b10 = a21 * a33 - a23 * a31;
|
|
2074
|
+
const b11 = a22 * a33 - a23 * a32;
|
|
2075
|
+
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
2076
|
+
if (!det) {
|
|
2077
|
+
return null;
|
|
2078
|
+
}
|
|
2079
|
+
det = 1 / det;
|
|
2080
|
+
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
2081
|
+
out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
2082
|
+
out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
2083
|
+
out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
2084
|
+
out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
2085
|
+
out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
2086
|
+
out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
2087
|
+
out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
2088
|
+
out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
2089
|
+
return out;
|
|
2090
|
+
}
|
|
2091
|
+
function projection(out, width, height) {
|
|
2092
|
+
out[0] = 2 / width;
|
|
2093
|
+
out[1] = 0;
|
|
2094
|
+
out[2] = 0;
|
|
2095
|
+
out[3] = 0;
|
|
2096
|
+
out[4] = -2 / height;
|
|
2097
|
+
out[5] = 0;
|
|
2098
|
+
out[6] = -1;
|
|
2099
|
+
out[7] = 1;
|
|
2100
|
+
out[8] = 1;
|
|
2101
|
+
return out;
|
|
2102
|
+
}
|
|
2103
|
+
function str3(a) {
|
|
2104
|
+
return `mat3(${a[0]}, ${a[1]}, ${a[2]}, ${a[3]}, ${a[4]}, ${a[5]}, ${a[6]}, ${a[7]}, ${a[8]})`;
|
|
2105
|
+
}
|
|
2106
|
+
function frob(a) {
|
|
2107
|
+
return Math.sqrt(
|
|
2108
|
+
a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + a[6] * a[6] + a[7] * a[7] + a[8] * a[8]
|
|
2109
|
+
);
|
|
2110
|
+
}
|
|
2111
|
+
function add3(out, a, b) {
|
|
2112
|
+
out[0] = a[0] + b[0];
|
|
2113
|
+
out[1] = a[1] + b[1];
|
|
2114
|
+
out[2] = a[2] + b[2];
|
|
2115
|
+
out[3] = a[3] + b[3];
|
|
2116
|
+
out[4] = a[4] + b[4];
|
|
2117
|
+
out[5] = a[5] + b[5];
|
|
2118
|
+
out[6] = a[6] + b[6];
|
|
2119
|
+
out[7] = a[7] + b[7];
|
|
2120
|
+
out[8] = a[8] + b[8];
|
|
2121
|
+
return out;
|
|
2122
|
+
}
|
|
2123
|
+
function subtract3(out, a, b) {
|
|
2124
|
+
out[0] = a[0] - b[0];
|
|
2125
|
+
out[1] = a[1] - b[1];
|
|
2126
|
+
out[2] = a[2] - b[2];
|
|
2127
|
+
out[3] = a[3] - b[3];
|
|
2128
|
+
out[4] = a[4] - b[4];
|
|
2129
|
+
out[5] = a[5] - b[5];
|
|
2130
|
+
out[6] = a[6] - b[6];
|
|
2131
|
+
out[7] = a[7] - b[7];
|
|
2132
|
+
out[8] = a[8] - b[8];
|
|
2133
|
+
return out;
|
|
2134
|
+
}
|
|
2135
|
+
function multiplyScalar(out, a, b) {
|
|
2136
|
+
out[0] = a[0] * b;
|
|
2137
|
+
out[1] = a[1] * b;
|
|
2138
|
+
out[2] = a[2] * b;
|
|
2139
|
+
out[3] = a[3] * b;
|
|
2140
|
+
out[4] = a[4] * b;
|
|
2141
|
+
out[5] = a[5] * b;
|
|
2142
|
+
out[6] = a[6] * b;
|
|
2143
|
+
out[7] = a[7] * b;
|
|
2144
|
+
out[8] = a[8] * b;
|
|
2145
|
+
return out;
|
|
2146
|
+
}
|
|
2147
|
+
function multiplyScalarAndAdd(out, a, b, scale7) {
|
|
2148
|
+
out[0] = a[0] + b[0] * scale7;
|
|
2149
|
+
out[1] = a[1] + b[1] * scale7;
|
|
2150
|
+
out[2] = a[2] + b[2] * scale7;
|
|
2151
|
+
out[3] = a[3] + b[3] * scale7;
|
|
2152
|
+
out[4] = a[4] + b[4] * scale7;
|
|
2153
|
+
out[5] = a[5] + b[5] * scale7;
|
|
2154
|
+
out[6] = a[6] + b[6] * scale7;
|
|
2155
|
+
out[7] = a[7] + b[7] * scale7;
|
|
2156
|
+
out[8] = a[8] + b[8] * scale7;
|
|
2157
|
+
return out;
|
|
2158
|
+
}
|
|
2159
|
+
function exactEquals4(a, b) {
|
|
2160
|
+
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];
|
|
2161
|
+
}
|
|
2162
|
+
function equals4(a, b) {
|
|
2163
|
+
const a0 = a[0];
|
|
2164
|
+
const a1 = a[1];
|
|
2165
|
+
const a2 = a[2];
|
|
2166
|
+
const a3 = a[3];
|
|
2167
|
+
const a4 = a[4];
|
|
2168
|
+
const a5 = a[5];
|
|
2169
|
+
const a6 = a[6];
|
|
2170
|
+
const a7 = a[7];
|
|
2171
|
+
const a8 = a[8];
|
|
2172
|
+
const b0 = b[0];
|
|
2173
|
+
const b1 = b[1];
|
|
2174
|
+
const b2 = b[2];
|
|
2175
|
+
const b3 = b[3];
|
|
2176
|
+
const b4 = b[4];
|
|
2177
|
+
const b5 = b[5];
|
|
2178
|
+
const b6 = b[6];
|
|
2179
|
+
const b7 = b[7];
|
|
2180
|
+
const b8 = b[8];
|
|
2181
|
+
return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= EPSILON * Math.max(1, Math.abs(a8), Math.abs(b8));
|
|
2182
|
+
}
|
|
2183
|
+
var mul3 = multiply3;
|
|
2184
|
+
var sub3 = subtract3;
|
|
1373
2185
|
|
|
1374
2186
|
// src/classes/matrix3.ts
|
|
1375
2187
|
var INDICES = /* @__PURE__ */ ((INDICES3) => {
|
|
@@ -1469,22 +2281,22 @@ var Matrix3 = class extends Matrix {
|
|
|
1469
2281
|
return this.check();
|
|
1470
2282
|
}
|
|
1471
2283
|
multiplyLeft(a) {
|
|
1472
|
-
|
|
2284
|
+
multiply3(this, a, this);
|
|
1473
2285
|
return this.check();
|
|
1474
2286
|
}
|
|
1475
2287
|
multiplyRight(a) {
|
|
1476
|
-
|
|
2288
|
+
multiply3(this, this, a);
|
|
1477
2289
|
return this.check();
|
|
1478
2290
|
}
|
|
1479
2291
|
rotate(radians2) {
|
|
1480
|
-
|
|
2292
|
+
rotate2(this, this, radians2);
|
|
1481
2293
|
return this.check();
|
|
1482
2294
|
}
|
|
1483
2295
|
scale(factor) {
|
|
1484
2296
|
if (Array.isArray(factor)) {
|
|
1485
|
-
|
|
2297
|
+
scale3(this, this, factor);
|
|
1486
2298
|
} else {
|
|
1487
|
-
|
|
2299
|
+
scale3(this, this, [factor, factor]);
|
|
1488
2300
|
}
|
|
1489
2301
|
return this.check();
|
|
1490
2302
|
}
|
|
@@ -1537,8 +2349,163 @@ function getIdentityMatrix() {
|
|
|
1537
2349
|
return IDENTITY_MATRIX3;
|
|
1538
2350
|
}
|
|
1539
2351
|
|
|
1540
|
-
// src/gl-matrix/mat4.
|
|
1541
|
-
|
|
2352
|
+
// src/gl-matrix/mat4.ts
|
|
2353
|
+
var mat4_exports = {};
|
|
2354
|
+
__export(mat4_exports, {
|
|
2355
|
+
add: () => add4,
|
|
2356
|
+
adjoint: () => adjoint2,
|
|
2357
|
+
clone: () => clone5,
|
|
2358
|
+
copy: () => copy4,
|
|
2359
|
+
create: () => create4,
|
|
2360
|
+
decompose: () => decompose,
|
|
2361
|
+
determinant: () => determinant2,
|
|
2362
|
+
equals: () => equals5,
|
|
2363
|
+
exactEquals: () => exactEquals5,
|
|
2364
|
+
frob: () => frob2,
|
|
2365
|
+
fromQuat: () => fromQuat3,
|
|
2366
|
+
fromQuat2: () => fromQuat2,
|
|
2367
|
+
fromRotation: () => fromRotation2,
|
|
2368
|
+
fromRotationTranslation: () => fromRotationTranslation,
|
|
2369
|
+
fromRotationTranslationScale: () => fromRotationTranslationScale,
|
|
2370
|
+
fromRotationTranslationScaleOrigin: () => fromRotationTranslationScaleOrigin,
|
|
2371
|
+
fromScaling: () => fromScaling2,
|
|
2372
|
+
fromTranslation: () => fromTranslation2,
|
|
2373
|
+
fromValues: () => fromValues4,
|
|
2374
|
+
fromXRotation: () => fromXRotation,
|
|
2375
|
+
fromYRotation: () => fromYRotation,
|
|
2376
|
+
fromZRotation: () => fromZRotation,
|
|
2377
|
+
frustum: () => frustum,
|
|
2378
|
+
getRotation: () => getRotation,
|
|
2379
|
+
getScaling: () => getScaling,
|
|
2380
|
+
getTranslation: () => getTranslation,
|
|
2381
|
+
identity: () => identity2,
|
|
2382
|
+
invert: () => invert2,
|
|
2383
|
+
lookAt: () => lookAt,
|
|
2384
|
+
mul: () => mul4,
|
|
2385
|
+
multiply: () => multiply4,
|
|
2386
|
+
multiplyScalar: () => multiplyScalar2,
|
|
2387
|
+
multiplyScalarAndAdd: () => multiplyScalarAndAdd2,
|
|
2388
|
+
ortho: () => ortho,
|
|
2389
|
+
orthoNO: () => orthoNO,
|
|
2390
|
+
orthoZO: () => orthoZO,
|
|
2391
|
+
perspective: () => perspective,
|
|
2392
|
+
perspectiveFromFieldOfView: () => perspectiveFromFieldOfView,
|
|
2393
|
+
perspectiveNO: () => perspectiveNO,
|
|
2394
|
+
perspectiveZO: () => perspectiveZO,
|
|
2395
|
+
rotate: () => rotate3,
|
|
2396
|
+
rotateX: () => rotateX2,
|
|
2397
|
+
rotateY: () => rotateY2,
|
|
2398
|
+
rotateZ: () => rotateZ2,
|
|
2399
|
+
scale: () => scale4,
|
|
2400
|
+
set: () => set4,
|
|
2401
|
+
str: () => str4,
|
|
2402
|
+
sub: () => sub4,
|
|
2403
|
+
subtract: () => subtract4,
|
|
2404
|
+
targetTo: () => targetTo,
|
|
2405
|
+
translate: () => translate2,
|
|
2406
|
+
transpose: () => transpose2
|
|
2407
|
+
});
|
|
2408
|
+
function create4() {
|
|
2409
|
+
const out = new ARRAY_TYPE(16);
|
|
2410
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
2411
|
+
out[1] = 0;
|
|
2412
|
+
out[2] = 0;
|
|
2413
|
+
out[3] = 0;
|
|
2414
|
+
out[4] = 0;
|
|
2415
|
+
out[6] = 0;
|
|
2416
|
+
out[7] = 0;
|
|
2417
|
+
out[8] = 0;
|
|
2418
|
+
out[9] = 0;
|
|
2419
|
+
out[11] = 0;
|
|
2420
|
+
out[12] = 0;
|
|
2421
|
+
out[13] = 0;
|
|
2422
|
+
out[14] = 0;
|
|
2423
|
+
}
|
|
2424
|
+
out[0] = 1;
|
|
2425
|
+
out[5] = 1;
|
|
2426
|
+
out[10] = 1;
|
|
2427
|
+
out[15] = 1;
|
|
2428
|
+
return out;
|
|
2429
|
+
}
|
|
2430
|
+
function clone5(a) {
|
|
2431
|
+
const out = new ARRAY_TYPE(16);
|
|
2432
|
+
out[0] = a[0];
|
|
2433
|
+
out[1] = a[1];
|
|
2434
|
+
out[2] = a[2];
|
|
2435
|
+
out[3] = a[3];
|
|
2436
|
+
out[4] = a[4];
|
|
2437
|
+
out[5] = a[5];
|
|
2438
|
+
out[6] = a[6];
|
|
2439
|
+
out[7] = a[7];
|
|
2440
|
+
out[8] = a[8];
|
|
2441
|
+
out[9] = a[9];
|
|
2442
|
+
out[10] = a[10];
|
|
2443
|
+
out[11] = a[11];
|
|
2444
|
+
out[12] = a[12];
|
|
2445
|
+
out[13] = a[13];
|
|
2446
|
+
out[14] = a[14];
|
|
2447
|
+
out[15] = a[15];
|
|
2448
|
+
return out;
|
|
2449
|
+
}
|
|
2450
|
+
function copy4(out, a) {
|
|
2451
|
+
out[0] = a[0];
|
|
2452
|
+
out[1] = a[1];
|
|
2453
|
+
out[2] = a[2];
|
|
2454
|
+
out[3] = a[3];
|
|
2455
|
+
out[4] = a[4];
|
|
2456
|
+
out[5] = a[5];
|
|
2457
|
+
out[6] = a[6];
|
|
2458
|
+
out[7] = a[7];
|
|
2459
|
+
out[8] = a[8];
|
|
2460
|
+
out[9] = a[9];
|
|
2461
|
+
out[10] = a[10];
|
|
2462
|
+
out[11] = a[11];
|
|
2463
|
+
out[12] = a[12];
|
|
2464
|
+
out[13] = a[13];
|
|
2465
|
+
out[14] = a[14];
|
|
2466
|
+
out[15] = a[15];
|
|
2467
|
+
return out;
|
|
2468
|
+
}
|
|
2469
|
+
function fromValues4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
2470
|
+
const out = new ARRAY_TYPE(16);
|
|
2471
|
+
out[0] = m00;
|
|
2472
|
+
out[1] = m01;
|
|
2473
|
+
out[2] = m02;
|
|
2474
|
+
out[3] = m03;
|
|
2475
|
+
out[4] = m10;
|
|
2476
|
+
out[5] = m11;
|
|
2477
|
+
out[6] = m12;
|
|
2478
|
+
out[7] = m13;
|
|
2479
|
+
out[8] = m20;
|
|
2480
|
+
out[9] = m21;
|
|
2481
|
+
out[10] = m22;
|
|
2482
|
+
out[11] = m23;
|
|
2483
|
+
out[12] = m30;
|
|
2484
|
+
out[13] = m31;
|
|
2485
|
+
out[14] = m32;
|
|
2486
|
+
out[15] = m33;
|
|
2487
|
+
return out;
|
|
2488
|
+
}
|
|
2489
|
+
function set4(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
2490
|
+
out[0] = m00;
|
|
2491
|
+
out[1] = m01;
|
|
2492
|
+
out[2] = m02;
|
|
2493
|
+
out[3] = m03;
|
|
2494
|
+
out[4] = m10;
|
|
2495
|
+
out[5] = m11;
|
|
2496
|
+
out[6] = m12;
|
|
2497
|
+
out[7] = m13;
|
|
2498
|
+
out[8] = m20;
|
|
2499
|
+
out[9] = m21;
|
|
2500
|
+
out[10] = m22;
|
|
2501
|
+
out[11] = m23;
|
|
2502
|
+
out[12] = m30;
|
|
2503
|
+
out[13] = m31;
|
|
2504
|
+
out[14] = m32;
|
|
2505
|
+
out[15] = m33;
|
|
2506
|
+
return out;
|
|
2507
|
+
}
|
|
2508
|
+
function identity2(out) {
|
|
1542
2509
|
out[0] = 1;
|
|
1543
2510
|
out[1] = 0;
|
|
1544
2511
|
out[2] = 0;
|
|
@@ -1649,6 +2616,53 @@ function invert2(out, a) {
|
|
|
1649
2616
|
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
1650
2617
|
return out;
|
|
1651
2618
|
}
|
|
2619
|
+
function adjoint2(out, a) {
|
|
2620
|
+
const a00 = a[0];
|
|
2621
|
+
const a01 = a[1];
|
|
2622
|
+
const a02 = a[2];
|
|
2623
|
+
const a03 = a[3];
|
|
2624
|
+
const a10 = a[4];
|
|
2625
|
+
const a11 = a[5];
|
|
2626
|
+
const a12 = a[6];
|
|
2627
|
+
const a13 = a[7];
|
|
2628
|
+
const a20 = a[8];
|
|
2629
|
+
const a21 = a[9];
|
|
2630
|
+
const a22 = a[10];
|
|
2631
|
+
const a23 = a[11];
|
|
2632
|
+
const a30 = a[12];
|
|
2633
|
+
const a31 = a[13];
|
|
2634
|
+
const a32 = a[14];
|
|
2635
|
+
const a33 = a[15];
|
|
2636
|
+
const b00 = a00 * a11 - a01 * a10;
|
|
2637
|
+
const b01 = a00 * a12 - a02 * a10;
|
|
2638
|
+
const b02 = a00 * a13 - a03 * a10;
|
|
2639
|
+
const b03 = a01 * a12 - a02 * a11;
|
|
2640
|
+
const b04 = a01 * a13 - a03 * a11;
|
|
2641
|
+
const b05 = a02 * a13 - a03 * a12;
|
|
2642
|
+
const b06 = a20 * a31 - a21 * a30;
|
|
2643
|
+
const b07 = a20 * a32 - a22 * a30;
|
|
2644
|
+
const b08 = a20 * a33 - a23 * a30;
|
|
2645
|
+
const b09 = a21 * a32 - a22 * a31;
|
|
2646
|
+
const b10 = a21 * a33 - a23 * a31;
|
|
2647
|
+
const b11 = a22 * a33 - a23 * a32;
|
|
2648
|
+
out[0] = a11 * b11 - a12 * b10 + a13 * b09;
|
|
2649
|
+
out[1] = a02 * b10 - a01 * b11 - a03 * b09;
|
|
2650
|
+
out[2] = a31 * b05 - a32 * b04 + a33 * b03;
|
|
2651
|
+
out[3] = a22 * b04 - a21 * b05 - a23 * b03;
|
|
2652
|
+
out[4] = a12 * b08 - a10 * b11 - a13 * b07;
|
|
2653
|
+
out[5] = a00 * b11 - a02 * b08 + a03 * b07;
|
|
2654
|
+
out[6] = a32 * b02 - a30 * b05 - a33 * b01;
|
|
2655
|
+
out[7] = a20 * b05 - a22 * b02 + a23 * b01;
|
|
2656
|
+
out[8] = a10 * b10 - a11 * b08 + a13 * b06;
|
|
2657
|
+
out[9] = a01 * b08 - a00 * b10 - a03 * b06;
|
|
2658
|
+
out[10] = a30 * b04 - a31 * b02 + a33 * b00;
|
|
2659
|
+
out[11] = a21 * b02 - a20 * b04 - a23 * b00;
|
|
2660
|
+
out[12] = a11 * b07 - a10 * b09 - a12 * b06;
|
|
2661
|
+
out[13] = a00 * b09 - a01 * b07 + a02 * b06;
|
|
2662
|
+
out[14] = a31 * b01 - a30 * b03 - a32 * b00;
|
|
2663
|
+
out[15] = a20 * b03 - a21 * b01 + a22 * b00;
|
|
2664
|
+
return out;
|
|
2665
|
+
}
|
|
1652
2666
|
function determinant2(a) {
|
|
1653
2667
|
const a00 = a[0];
|
|
1654
2668
|
const a01 = a[1];
|
|
@@ -1678,7 +2692,7 @@ function determinant2(a) {
|
|
|
1678
2692
|
const b9 = a30 * b2 - a31 * b1 + a32 * b0;
|
|
1679
2693
|
return a13 * b6 - a03 * b7 + a33 * b8 - a23 * b9;
|
|
1680
2694
|
}
|
|
1681
|
-
function
|
|
2695
|
+
function multiply4(out, a, b) {
|
|
1682
2696
|
const a00 = a[0];
|
|
1683
2697
|
const a01 = a[1];
|
|
1684
2698
|
const a02 = a[2];
|
|
@@ -1782,7 +2796,7 @@ function translate2(out, a, v) {
|
|
|
1782
2796
|
}
|
|
1783
2797
|
return out;
|
|
1784
2798
|
}
|
|
1785
|
-
function
|
|
2799
|
+
function scale4(out, a, v) {
|
|
1786
2800
|
const x = v[0];
|
|
1787
2801
|
const y = v[1];
|
|
1788
2802
|
const z = v[2];
|
|
@@ -1804,11 +2818,11 @@ function scale2(out, a, v) {
|
|
|
1804
2818
|
out[15] = a[15];
|
|
1805
2819
|
return out;
|
|
1806
2820
|
}
|
|
1807
|
-
function
|
|
2821
|
+
function rotate3(out, a, rad, axis) {
|
|
1808
2822
|
let x = axis[0];
|
|
1809
2823
|
let y = axis[1];
|
|
1810
2824
|
let z = axis[2];
|
|
1811
|
-
let
|
|
2825
|
+
let len5 = Math.sqrt(x * x + y * y + z * z);
|
|
1812
2826
|
let c;
|
|
1813
2827
|
let s;
|
|
1814
2828
|
let t;
|
|
@@ -1833,13 +2847,13 @@ function rotate2(out, a, rad, axis) {
|
|
|
1833
2847
|
let b20;
|
|
1834
2848
|
let b21;
|
|
1835
2849
|
let b22;
|
|
1836
|
-
if (
|
|
2850
|
+
if (len5 < EPSILON) {
|
|
1837
2851
|
return null;
|
|
1838
2852
|
}
|
|
1839
|
-
|
|
1840
|
-
x *=
|
|
1841
|
-
y *=
|
|
1842
|
-
z *=
|
|
2853
|
+
len5 = 1 / len5;
|
|
2854
|
+
x *= len5;
|
|
2855
|
+
y *= len5;
|
|
2856
|
+
z *= len5;
|
|
1843
2857
|
s = Math.sin(rad);
|
|
1844
2858
|
c = Math.cos(rad);
|
|
1845
2859
|
t = 1 - c;
|
|
@@ -1946,38 +2960,443 @@ function rotateY2(out, a, rad) {
|
|
|
1946
2960
|
out[11] = a03 * s + a23 * c;
|
|
1947
2961
|
return out;
|
|
1948
2962
|
}
|
|
1949
|
-
function rotateZ2(out, a, rad) {
|
|
1950
|
-
const s = Math.sin(rad);
|
|
1951
|
-
const c = Math.cos(rad);
|
|
1952
|
-
const a00 = a[0];
|
|
1953
|
-
const a01 = a[1];
|
|
1954
|
-
const a02 = a[2];
|
|
1955
|
-
const a03 = a[3];
|
|
1956
|
-
const a10 = a[4];
|
|
1957
|
-
const a11 = a[5];
|
|
1958
|
-
const a12 = a[6];
|
|
1959
|
-
const a13 = a[7];
|
|
1960
|
-
if (a !== out) {
|
|
1961
|
-
out[8] = a[8];
|
|
1962
|
-
out[9] = a[9];
|
|
1963
|
-
out[10] = a[10];
|
|
1964
|
-
out[11] = a[11];
|
|
1965
|
-
out[12] = a[12];
|
|
1966
|
-
out[13] = a[13];
|
|
1967
|
-
out[14] = a[14];
|
|
1968
|
-
out[15] = a[15];
|
|
1969
|
-
}
|
|
1970
|
-
out[0] = a00 * c + a10 * s;
|
|
1971
|
-
out[1] = a01 * c + a11 * s;
|
|
1972
|
-
out[2] = a02 * c + a12 * s;
|
|
1973
|
-
out[3] = a03 * c + a13 * s;
|
|
1974
|
-
out[4] = a10 * c - a00 * s;
|
|
1975
|
-
out[5] = a11 * c - a01 * s;
|
|
1976
|
-
out[6] = a12 * c - a02 * s;
|
|
1977
|
-
out[7] = a13 * c - a03 * s;
|
|
2963
|
+
function rotateZ2(out, a, rad) {
|
|
2964
|
+
const s = Math.sin(rad);
|
|
2965
|
+
const c = Math.cos(rad);
|
|
2966
|
+
const a00 = a[0];
|
|
2967
|
+
const a01 = a[1];
|
|
2968
|
+
const a02 = a[2];
|
|
2969
|
+
const a03 = a[3];
|
|
2970
|
+
const a10 = a[4];
|
|
2971
|
+
const a11 = a[5];
|
|
2972
|
+
const a12 = a[6];
|
|
2973
|
+
const a13 = a[7];
|
|
2974
|
+
if (a !== out) {
|
|
2975
|
+
out[8] = a[8];
|
|
2976
|
+
out[9] = a[9];
|
|
2977
|
+
out[10] = a[10];
|
|
2978
|
+
out[11] = a[11];
|
|
2979
|
+
out[12] = a[12];
|
|
2980
|
+
out[13] = a[13];
|
|
2981
|
+
out[14] = a[14];
|
|
2982
|
+
out[15] = a[15];
|
|
2983
|
+
}
|
|
2984
|
+
out[0] = a00 * c + a10 * s;
|
|
2985
|
+
out[1] = a01 * c + a11 * s;
|
|
2986
|
+
out[2] = a02 * c + a12 * s;
|
|
2987
|
+
out[3] = a03 * c + a13 * s;
|
|
2988
|
+
out[4] = a10 * c - a00 * s;
|
|
2989
|
+
out[5] = a11 * c - a01 * s;
|
|
2990
|
+
out[6] = a12 * c - a02 * s;
|
|
2991
|
+
out[7] = a13 * c - a03 * s;
|
|
2992
|
+
return out;
|
|
2993
|
+
}
|
|
2994
|
+
function fromTranslation2(out, v) {
|
|
2995
|
+
out[0] = 1;
|
|
2996
|
+
out[1] = 0;
|
|
2997
|
+
out[2] = 0;
|
|
2998
|
+
out[3] = 0;
|
|
2999
|
+
out[4] = 0;
|
|
3000
|
+
out[5] = 1;
|
|
3001
|
+
out[6] = 0;
|
|
3002
|
+
out[7] = 0;
|
|
3003
|
+
out[8] = 0;
|
|
3004
|
+
out[9] = 0;
|
|
3005
|
+
out[10] = 1;
|
|
3006
|
+
out[11] = 0;
|
|
3007
|
+
out[12] = v[0];
|
|
3008
|
+
out[13] = v[1];
|
|
3009
|
+
out[14] = v[2];
|
|
3010
|
+
out[15] = 1;
|
|
3011
|
+
return out;
|
|
3012
|
+
}
|
|
3013
|
+
function fromScaling2(out, v) {
|
|
3014
|
+
out[0] = v[0];
|
|
3015
|
+
out[1] = 0;
|
|
3016
|
+
out[2] = 0;
|
|
3017
|
+
out[3] = 0;
|
|
3018
|
+
out[4] = 0;
|
|
3019
|
+
out[5] = v[1];
|
|
3020
|
+
out[6] = 0;
|
|
3021
|
+
out[7] = 0;
|
|
3022
|
+
out[8] = 0;
|
|
3023
|
+
out[9] = 0;
|
|
3024
|
+
out[10] = v[2];
|
|
3025
|
+
out[11] = 0;
|
|
3026
|
+
out[12] = 0;
|
|
3027
|
+
out[13] = 0;
|
|
3028
|
+
out[14] = 0;
|
|
3029
|
+
out[15] = 1;
|
|
3030
|
+
return out;
|
|
3031
|
+
}
|
|
3032
|
+
function fromRotation2(out, rad, axis) {
|
|
3033
|
+
let x = axis[0];
|
|
3034
|
+
let y = axis[1];
|
|
3035
|
+
let z = axis[2];
|
|
3036
|
+
let len5 = Math.sqrt(x * x + y * y + z * z);
|
|
3037
|
+
let c;
|
|
3038
|
+
let s;
|
|
3039
|
+
let t;
|
|
3040
|
+
if (len5 < EPSILON) {
|
|
3041
|
+
return null;
|
|
3042
|
+
}
|
|
3043
|
+
len5 = 1 / len5;
|
|
3044
|
+
x *= len5;
|
|
3045
|
+
y *= len5;
|
|
3046
|
+
z *= len5;
|
|
3047
|
+
s = Math.sin(rad);
|
|
3048
|
+
c = Math.cos(rad);
|
|
3049
|
+
t = 1 - c;
|
|
3050
|
+
out[0] = x * x * t + c;
|
|
3051
|
+
out[1] = y * x * t + z * s;
|
|
3052
|
+
out[2] = z * x * t - y * s;
|
|
3053
|
+
out[3] = 0;
|
|
3054
|
+
out[4] = x * y * t - z * s;
|
|
3055
|
+
out[5] = y * y * t + c;
|
|
3056
|
+
out[6] = z * y * t + x * s;
|
|
3057
|
+
out[7] = 0;
|
|
3058
|
+
out[8] = x * z * t + y * s;
|
|
3059
|
+
out[9] = y * z * t - x * s;
|
|
3060
|
+
out[10] = z * z * t + c;
|
|
3061
|
+
out[11] = 0;
|
|
3062
|
+
out[12] = 0;
|
|
3063
|
+
out[13] = 0;
|
|
3064
|
+
out[14] = 0;
|
|
3065
|
+
out[15] = 1;
|
|
3066
|
+
return out;
|
|
3067
|
+
}
|
|
3068
|
+
function fromXRotation(out, rad) {
|
|
3069
|
+
const s = Math.sin(rad);
|
|
3070
|
+
const c = Math.cos(rad);
|
|
3071
|
+
out[0] = 1;
|
|
3072
|
+
out[1] = 0;
|
|
3073
|
+
out[2] = 0;
|
|
3074
|
+
out[3] = 0;
|
|
3075
|
+
out[4] = 0;
|
|
3076
|
+
out[5] = c;
|
|
3077
|
+
out[6] = s;
|
|
3078
|
+
out[7] = 0;
|
|
3079
|
+
out[8] = 0;
|
|
3080
|
+
out[9] = -s;
|
|
3081
|
+
out[10] = c;
|
|
3082
|
+
out[11] = 0;
|
|
3083
|
+
out[12] = 0;
|
|
3084
|
+
out[13] = 0;
|
|
3085
|
+
out[14] = 0;
|
|
3086
|
+
out[15] = 1;
|
|
3087
|
+
return out;
|
|
3088
|
+
}
|
|
3089
|
+
function fromYRotation(out, rad) {
|
|
3090
|
+
const s = Math.sin(rad);
|
|
3091
|
+
const c = Math.cos(rad);
|
|
3092
|
+
out[0] = c;
|
|
3093
|
+
out[1] = 0;
|
|
3094
|
+
out[2] = -s;
|
|
3095
|
+
out[3] = 0;
|
|
3096
|
+
out[4] = 0;
|
|
3097
|
+
out[5] = 1;
|
|
3098
|
+
out[6] = 0;
|
|
3099
|
+
out[7] = 0;
|
|
3100
|
+
out[8] = s;
|
|
3101
|
+
out[9] = 0;
|
|
3102
|
+
out[10] = c;
|
|
3103
|
+
out[11] = 0;
|
|
3104
|
+
out[12] = 0;
|
|
3105
|
+
out[13] = 0;
|
|
3106
|
+
out[14] = 0;
|
|
3107
|
+
out[15] = 1;
|
|
3108
|
+
return out;
|
|
3109
|
+
}
|
|
3110
|
+
function fromZRotation(out, rad) {
|
|
3111
|
+
const s = Math.sin(rad);
|
|
3112
|
+
const c = Math.cos(rad);
|
|
3113
|
+
out[0] = c;
|
|
3114
|
+
out[1] = s;
|
|
3115
|
+
out[2] = 0;
|
|
3116
|
+
out[3] = 0;
|
|
3117
|
+
out[4] = -s;
|
|
3118
|
+
out[5] = c;
|
|
3119
|
+
out[6] = 0;
|
|
3120
|
+
out[7] = 0;
|
|
3121
|
+
out[8] = 0;
|
|
3122
|
+
out[9] = 0;
|
|
3123
|
+
out[10] = 1;
|
|
3124
|
+
out[11] = 0;
|
|
3125
|
+
out[12] = 0;
|
|
3126
|
+
out[13] = 0;
|
|
3127
|
+
out[14] = 0;
|
|
3128
|
+
out[15] = 1;
|
|
3129
|
+
return out;
|
|
3130
|
+
}
|
|
3131
|
+
function fromRotationTranslation(out, q, v) {
|
|
3132
|
+
const x = q[0];
|
|
3133
|
+
const y = q[1];
|
|
3134
|
+
const z = q[2];
|
|
3135
|
+
const w = q[3];
|
|
3136
|
+
const x2 = x + x;
|
|
3137
|
+
const y2 = y + y;
|
|
3138
|
+
const z2 = z + z;
|
|
3139
|
+
const xx = x * x2;
|
|
3140
|
+
const xy = x * y2;
|
|
3141
|
+
const xz = x * z2;
|
|
3142
|
+
const yy = y * y2;
|
|
3143
|
+
const yz = y * z2;
|
|
3144
|
+
const zz = z * z2;
|
|
3145
|
+
const wx = w * x2;
|
|
3146
|
+
const wy = w * y2;
|
|
3147
|
+
const wz = w * z2;
|
|
3148
|
+
out[0] = 1 - (yy + zz);
|
|
3149
|
+
out[1] = xy + wz;
|
|
3150
|
+
out[2] = xz - wy;
|
|
3151
|
+
out[3] = 0;
|
|
3152
|
+
out[4] = xy - wz;
|
|
3153
|
+
out[5] = 1 - (xx + zz);
|
|
3154
|
+
out[6] = yz + wx;
|
|
3155
|
+
out[7] = 0;
|
|
3156
|
+
out[8] = xz + wy;
|
|
3157
|
+
out[9] = yz - wx;
|
|
3158
|
+
out[10] = 1 - (xx + yy);
|
|
3159
|
+
out[11] = 0;
|
|
3160
|
+
out[12] = v[0];
|
|
3161
|
+
out[13] = v[1];
|
|
3162
|
+
out[14] = v[2];
|
|
3163
|
+
out[15] = 1;
|
|
3164
|
+
return out;
|
|
3165
|
+
}
|
|
3166
|
+
function fromQuat2(out, a) {
|
|
3167
|
+
const translation = new ARRAY_TYPE(3);
|
|
3168
|
+
const bx = -a[0];
|
|
3169
|
+
const by = -a[1];
|
|
3170
|
+
const bz = -a[2];
|
|
3171
|
+
const bw = a[3];
|
|
3172
|
+
const ax = a[4];
|
|
3173
|
+
const ay = a[5];
|
|
3174
|
+
const az = a[6];
|
|
3175
|
+
const aw = a[7];
|
|
3176
|
+
const magnitude = bx * bx + by * by + bz * bz + bw * bw;
|
|
3177
|
+
if (magnitude > 0) {
|
|
3178
|
+
translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;
|
|
3179
|
+
translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;
|
|
3180
|
+
translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;
|
|
3181
|
+
} else {
|
|
3182
|
+
translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;
|
|
3183
|
+
translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;
|
|
3184
|
+
translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;
|
|
3185
|
+
}
|
|
3186
|
+
fromRotationTranslation(out, a, translation);
|
|
3187
|
+
return out;
|
|
3188
|
+
}
|
|
3189
|
+
function getTranslation(out, mat) {
|
|
3190
|
+
out[0] = mat[12];
|
|
3191
|
+
out[1] = mat[13];
|
|
3192
|
+
out[2] = mat[14];
|
|
3193
|
+
return out;
|
|
3194
|
+
}
|
|
3195
|
+
function getScaling(out, mat) {
|
|
3196
|
+
const m11 = mat[0];
|
|
3197
|
+
const m12 = mat[1];
|
|
3198
|
+
const m13 = mat[2];
|
|
3199
|
+
const m21 = mat[4];
|
|
3200
|
+
const m22 = mat[5];
|
|
3201
|
+
const m23 = mat[6];
|
|
3202
|
+
const m31 = mat[8];
|
|
3203
|
+
const m32 = mat[9];
|
|
3204
|
+
const m33 = mat[10];
|
|
3205
|
+
out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);
|
|
3206
|
+
out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);
|
|
3207
|
+
out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);
|
|
3208
|
+
return out;
|
|
3209
|
+
}
|
|
3210
|
+
function getRotation(out, mat) {
|
|
3211
|
+
const scaling = new ARRAY_TYPE(3);
|
|
3212
|
+
getScaling(scaling, mat);
|
|
3213
|
+
const is1 = 1 / scaling[0];
|
|
3214
|
+
const is2 = 1 / scaling[1];
|
|
3215
|
+
const is3 = 1 / scaling[2];
|
|
3216
|
+
const sm11 = mat[0] * is1;
|
|
3217
|
+
const sm12 = mat[1] * is2;
|
|
3218
|
+
const sm13 = mat[2] * is3;
|
|
3219
|
+
const sm21 = mat[4] * is1;
|
|
3220
|
+
const sm22 = mat[5] * is2;
|
|
3221
|
+
const sm23 = mat[6] * is3;
|
|
3222
|
+
const sm31 = mat[8] * is1;
|
|
3223
|
+
const sm32 = mat[9] * is2;
|
|
3224
|
+
const sm33 = mat[10] * is3;
|
|
3225
|
+
const trace = sm11 + sm22 + sm33;
|
|
3226
|
+
let S = 0;
|
|
3227
|
+
if (trace > 0) {
|
|
3228
|
+
S = Math.sqrt(trace + 1) * 2;
|
|
3229
|
+
out[3] = 0.25 * S;
|
|
3230
|
+
out[0] = (sm23 - sm32) / S;
|
|
3231
|
+
out[1] = (sm31 - sm13) / S;
|
|
3232
|
+
out[2] = (sm12 - sm21) / S;
|
|
3233
|
+
} else if (sm11 > sm22 && sm11 > sm33) {
|
|
3234
|
+
S = Math.sqrt(1 + sm11 - sm22 - sm33) * 2;
|
|
3235
|
+
out[3] = (sm23 - sm32) / S;
|
|
3236
|
+
out[0] = 0.25 * S;
|
|
3237
|
+
out[1] = (sm12 + sm21) / S;
|
|
3238
|
+
out[2] = (sm31 + sm13) / S;
|
|
3239
|
+
} else if (sm22 > sm33) {
|
|
3240
|
+
S = Math.sqrt(1 + sm22 - sm11 - sm33) * 2;
|
|
3241
|
+
out[3] = (sm31 - sm13) / S;
|
|
3242
|
+
out[0] = (sm12 + sm21) / S;
|
|
3243
|
+
out[1] = 0.25 * S;
|
|
3244
|
+
out[2] = (sm23 + sm32) / S;
|
|
3245
|
+
} else {
|
|
3246
|
+
S = Math.sqrt(1 + sm33 - sm11 - sm22) * 2;
|
|
3247
|
+
out[3] = (sm12 - sm21) / S;
|
|
3248
|
+
out[0] = (sm31 + sm13) / S;
|
|
3249
|
+
out[1] = (sm23 + sm32) / S;
|
|
3250
|
+
out[2] = 0.25 * S;
|
|
3251
|
+
}
|
|
3252
|
+
return out;
|
|
3253
|
+
}
|
|
3254
|
+
function decompose(out_r, out_t, out_s, mat) {
|
|
3255
|
+
out_t[0] = mat[12];
|
|
3256
|
+
out_t[1] = mat[13];
|
|
3257
|
+
out_t[2] = mat[14];
|
|
3258
|
+
const m11 = mat[0];
|
|
3259
|
+
const m12 = mat[1];
|
|
3260
|
+
const m13 = mat[2];
|
|
3261
|
+
const m21 = mat[4];
|
|
3262
|
+
const m22 = mat[5];
|
|
3263
|
+
const m23 = mat[6];
|
|
3264
|
+
const m31 = mat[8];
|
|
3265
|
+
const m32 = mat[9];
|
|
3266
|
+
const m33 = mat[10];
|
|
3267
|
+
out_s[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);
|
|
3268
|
+
out_s[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);
|
|
3269
|
+
out_s[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);
|
|
3270
|
+
const is1 = 1 / out_s[0];
|
|
3271
|
+
const is2 = 1 / out_s[1];
|
|
3272
|
+
const is3 = 1 / out_s[2];
|
|
3273
|
+
const sm11 = m11 * is1;
|
|
3274
|
+
const sm12 = m12 * is2;
|
|
3275
|
+
const sm13 = m13 * is3;
|
|
3276
|
+
const sm21 = m21 * is1;
|
|
3277
|
+
const sm22 = m22 * is2;
|
|
3278
|
+
const sm23 = m23 * is3;
|
|
3279
|
+
const sm31 = m31 * is1;
|
|
3280
|
+
const sm32 = m32 * is2;
|
|
3281
|
+
const sm33 = m33 * is3;
|
|
3282
|
+
const trace = sm11 + sm22 + sm33;
|
|
3283
|
+
let S = 0;
|
|
3284
|
+
if (trace > 0) {
|
|
3285
|
+
S = Math.sqrt(trace + 1) * 2;
|
|
3286
|
+
out_r[3] = 0.25 * S;
|
|
3287
|
+
out_r[0] = (sm23 - sm32) / S;
|
|
3288
|
+
out_r[1] = (sm31 - sm13) / S;
|
|
3289
|
+
out_r[2] = (sm12 - sm21) / S;
|
|
3290
|
+
} else if (sm11 > sm22 && sm11 > sm33) {
|
|
3291
|
+
S = Math.sqrt(1 + sm11 - sm22 - sm33) * 2;
|
|
3292
|
+
out_r[3] = (sm23 - sm32) / S;
|
|
3293
|
+
out_r[0] = 0.25 * S;
|
|
3294
|
+
out_r[1] = (sm12 + sm21) / S;
|
|
3295
|
+
out_r[2] = (sm31 + sm13) / S;
|
|
3296
|
+
} else if (sm22 > sm33) {
|
|
3297
|
+
S = Math.sqrt(1 + sm22 - sm11 - sm33) * 2;
|
|
3298
|
+
out_r[3] = (sm31 - sm13) / S;
|
|
3299
|
+
out_r[0] = (sm12 + sm21) / S;
|
|
3300
|
+
out_r[1] = 0.25 * S;
|
|
3301
|
+
out_r[2] = (sm23 + sm32) / S;
|
|
3302
|
+
} else {
|
|
3303
|
+
S = Math.sqrt(1 + sm33 - sm11 - sm22) * 2;
|
|
3304
|
+
out_r[3] = (sm12 - sm21) / S;
|
|
3305
|
+
out_r[0] = (sm31 + sm13) / S;
|
|
3306
|
+
out_r[1] = (sm23 + sm32) / S;
|
|
3307
|
+
out_r[2] = 0.25 * S;
|
|
3308
|
+
}
|
|
3309
|
+
return out_r;
|
|
3310
|
+
}
|
|
3311
|
+
function fromRotationTranslationScale(out, q, v, s) {
|
|
3312
|
+
const x = q[0];
|
|
3313
|
+
const y = q[1];
|
|
3314
|
+
const z = q[2];
|
|
3315
|
+
const w = q[3];
|
|
3316
|
+
const x2 = x + x;
|
|
3317
|
+
const y2 = y + y;
|
|
3318
|
+
const z2 = z + z;
|
|
3319
|
+
const xx = x * x2;
|
|
3320
|
+
const xy = x * y2;
|
|
3321
|
+
const xz = x * z2;
|
|
3322
|
+
const yy = y * y2;
|
|
3323
|
+
const yz = y * z2;
|
|
3324
|
+
const zz = z * z2;
|
|
3325
|
+
const wx = w * x2;
|
|
3326
|
+
const wy = w * y2;
|
|
3327
|
+
const wz = w * z2;
|
|
3328
|
+
const sx = s[0];
|
|
3329
|
+
const sy = s[1];
|
|
3330
|
+
const sz = s[2];
|
|
3331
|
+
out[0] = (1 - (yy + zz)) * sx;
|
|
3332
|
+
out[1] = (xy + wz) * sx;
|
|
3333
|
+
out[2] = (xz - wy) * sx;
|
|
3334
|
+
out[3] = 0;
|
|
3335
|
+
out[4] = (xy - wz) * sy;
|
|
3336
|
+
out[5] = (1 - (xx + zz)) * sy;
|
|
3337
|
+
out[6] = (yz + wx) * sy;
|
|
3338
|
+
out[7] = 0;
|
|
3339
|
+
out[8] = (xz + wy) * sz;
|
|
3340
|
+
out[9] = (yz - wx) * sz;
|
|
3341
|
+
out[10] = (1 - (xx + yy)) * sz;
|
|
3342
|
+
out[11] = 0;
|
|
3343
|
+
out[12] = v[0];
|
|
3344
|
+
out[13] = v[1];
|
|
3345
|
+
out[14] = v[2];
|
|
3346
|
+
out[15] = 1;
|
|
3347
|
+
return out;
|
|
3348
|
+
}
|
|
3349
|
+
function fromRotationTranslationScaleOrigin(out, q, v, s, o) {
|
|
3350
|
+
const x = q[0];
|
|
3351
|
+
const y = q[1];
|
|
3352
|
+
const z = q[2];
|
|
3353
|
+
const w = q[3];
|
|
3354
|
+
const x2 = x + x;
|
|
3355
|
+
const y2 = y + y;
|
|
3356
|
+
const z2 = z + z;
|
|
3357
|
+
const xx = x * x2;
|
|
3358
|
+
const xy = x * y2;
|
|
3359
|
+
const xz = x * z2;
|
|
3360
|
+
const yy = y * y2;
|
|
3361
|
+
const yz = y * z2;
|
|
3362
|
+
const zz = z * z2;
|
|
3363
|
+
const wx = w * x2;
|
|
3364
|
+
const wy = w * y2;
|
|
3365
|
+
const wz = w * z2;
|
|
3366
|
+
const sx = s[0];
|
|
3367
|
+
const sy = s[1];
|
|
3368
|
+
const sz = s[2];
|
|
3369
|
+
const ox = o[0];
|
|
3370
|
+
const oy = o[1];
|
|
3371
|
+
const oz = o[2];
|
|
3372
|
+
const out0 = (1 - (yy + zz)) * sx;
|
|
3373
|
+
const out1 = (xy + wz) * sx;
|
|
3374
|
+
const out2 = (xz - wy) * sx;
|
|
3375
|
+
const out4 = (xy - wz) * sy;
|
|
3376
|
+
const out5 = (1 - (xx + zz)) * sy;
|
|
3377
|
+
const out6 = (yz + wx) * sy;
|
|
3378
|
+
const out8 = (xz + wy) * sz;
|
|
3379
|
+
const out9 = (yz - wx) * sz;
|
|
3380
|
+
const out10 = (1 - (xx + yy)) * sz;
|
|
3381
|
+
out[0] = out0;
|
|
3382
|
+
out[1] = out1;
|
|
3383
|
+
out[2] = out2;
|
|
3384
|
+
out[3] = 0;
|
|
3385
|
+
out[4] = out4;
|
|
3386
|
+
out[5] = out5;
|
|
3387
|
+
out[6] = out6;
|
|
3388
|
+
out[7] = 0;
|
|
3389
|
+
out[8] = out8;
|
|
3390
|
+
out[9] = out9;
|
|
3391
|
+
out[10] = out10;
|
|
3392
|
+
out[11] = 0;
|
|
3393
|
+
out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);
|
|
3394
|
+
out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);
|
|
3395
|
+
out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);
|
|
3396
|
+
out[15] = 1;
|
|
1978
3397
|
return out;
|
|
1979
3398
|
}
|
|
1980
|
-
function
|
|
3399
|
+
function fromQuat3(out, q) {
|
|
1981
3400
|
const x = q[0];
|
|
1982
3401
|
const y = q[1];
|
|
1983
3402
|
const z = q[2];
|
|
@@ -2061,6 +3480,57 @@ function perspectiveNO(out, fovy, aspect, near, far) {
|
|
|
2061
3480
|
return out;
|
|
2062
3481
|
}
|
|
2063
3482
|
var perspective = perspectiveNO;
|
|
3483
|
+
function perspectiveZO(out, fovy, aspect, near, far) {
|
|
3484
|
+
const f = 1 / Math.tan(fovy / 2);
|
|
3485
|
+
out[0] = f / aspect;
|
|
3486
|
+
out[1] = 0;
|
|
3487
|
+
out[2] = 0;
|
|
3488
|
+
out[3] = 0;
|
|
3489
|
+
out[4] = 0;
|
|
3490
|
+
out[5] = f;
|
|
3491
|
+
out[6] = 0;
|
|
3492
|
+
out[7] = 0;
|
|
3493
|
+
out[8] = 0;
|
|
3494
|
+
out[9] = 0;
|
|
3495
|
+
out[11] = -1;
|
|
3496
|
+
out[12] = 0;
|
|
3497
|
+
out[13] = 0;
|
|
3498
|
+
out[15] = 0;
|
|
3499
|
+
if (far != null && far !== Infinity) {
|
|
3500
|
+
const nf = 1 / (near - far);
|
|
3501
|
+
out[10] = far * nf;
|
|
3502
|
+
out[14] = far * near * nf;
|
|
3503
|
+
} else {
|
|
3504
|
+
out[10] = -1;
|
|
3505
|
+
out[14] = -near;
|
|
3506
|
+
}
|
|
3507
|
+
return out;
|
|
3508
|
+
}
|
|
3509
|
+
function perspectiveFromFieldOfView(out, fov, near, far) {
|
|
3510
|
+
const upTan = Math.tan(fov.upDegrees * Math.PI / 180);
|
|
3511
|
+
const downTan = Math.tan(fov.downDegrees * Math.PI / 180);
|
|
3512
|
+
const leftTan = Math.tan(fov.leftDegrees * Math.PI / 180);
|
|
3513
|
+
const rightTan = Math.tan(fov.rightDegrees * Math.PI / 180);
|
|
3514
|
+
const xScale = 2 / (leftTan + rightTan);
|
|
3515
|
+
const yScale = 2 / (upTan + downTan);
|
|
3516
|
+
out[0] = xScale;
|
|
3517
|
+
out[1] = 0;
|
|
3518
|
+
out[2] = 0;
|
|
3519
|
+
out[3] = 0;
|
|
3520
|
+
out[4] = 0;
|
|
3521
|
+
out[5] = yScale;
|
|
3522
|
+
out[6] = 0;
|
|
3523
|
+
out[7] = 0;
|
|
3524
|
+
out[8] = -((leftTan - rightTan) * xScale * 0.5);
|
|
3525
|
+
out[9] = (upTan - downTan) * yScale * 0.5;
|
|
3526
|
+
out[10] = far / (near - far);
|
|
3527
|
+
out[11] = -1;
|
|
3528
|
+
out[12] = 0;
|
|
3529
|
+
out[13] = 0;
|
|
3530
|
+
out[14] = far * near / (near - far);
|
|
3531
|
+
out[15] = 0;
|
|
3532
|
+
return out;
|
|
3533
|
+
}
|
|
2064
3534
|
function orthoNO(out, left, right, bottom, top, near, far) {
|
|
2065
3535
|
const lr = 1 / (left - right);
|
|
2066
3536
|
const bt = 1 / (bottom - top);
|
|
@@ -2084,8 +3554,30 @@ function orthoNO(out, left, right, bottom, top, near, far) {
|
|
|
2084
3554
|
return out;
|
|
2085
3555
|
}
|
|
2086
3556
|
var ortho = orthoNO;
|
|
3557
|
+
function orthoZO(out, left, right, bottom, top, near, far) {
|
|
3558
|
+
const lr = 1 / (left - right);
|
|
3559
|
+
const bt = 1 / (bottom - top);
|
|
3560
|
+
const nf = 1 / (near - far);
|
|
3561
|
+
out[0] = -2 * lr;
|
|
3562
|
+
out[1] = 0;
|
|
3563
|
+
out[2] = 0;
|
|
3564
|
+
out[3] = 0;
|
|
3565
|
+
out[4] = 0;
|
|
3566
|
+
out[5] = -2 * bt;
|
|
3567
|
+
out[6] = 0;
|
|
3568
|
+
out[7] = 0;
|
|
3569
|
+
out[8] = 0;
|
|
3570
|
+
out[9] = 0;
|
|
3571
|
+
out[10] = nf;
|
|
3572
|
+
out[11] = 0;
|
|
3573
|
+
out[12] = (left + right) * lr;
|
|
3574
|
+
out[13] = (top + bottom) * bt;
|
|
3575
|
+
out[14] = near * nf;
|
|
3576
|
+
out[15] = 1;
|
|
3577
|
+
return out;
|
|
3578
|
+
}
|
|
2087
3579
|
function lookAt(out, eye, center, up) {
|
|
2088
|
-
let
|
|
3580
|
+
let len5;
|
|
2089
3581
|
let x0;
|
|
2090
3582
|
let x1;
|
|
2091
3583
|
let x2;
|
|
@@ -2105,42 +3597,42 @@ function lookAt(out, eye, center, up) {
|
|
|
2105
3597
|
const centery = center[1];
|
|
2106
3598
|
const centerz = center[2];
|
|
2107
3599
|
if (Math.abs(eyex - centerx) < EPSILON && Math.abs(eyey - centery) < EPSILON && Math.abs(eyez - centerz) < EPSILON) {
|
|
2108
|
-
return
|
|
3600
|
+
return identity2(out);
|
|
2109
3601
|
}
|
|
2110
3602
|
z0 = eyex - centerx;
|
|
2111
3603
|
z1 = eyey - centery;
|
|
2112
3604
|
z2 = eyez - centerz;
|
|
2113
|
-
|
|
2114
|
-
z0 *=
|
|
2115
|
-
z1 *=
|
|
2116
|
-
z2 *=
|
|
3605
|
+
len5 = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
|
|
3606
|
+
z0 *= len5;
|
|
3607
|
+
z1 *= len5;
|
|
3608
|
+
z2 *= len5;
|
|
2117
3609
|
x0 = upy * z2 - upz * z1;
|
|
2118
3610
|
x1 = upz * z0 - upx * z2;
|
|
2119
3611
|
x2 = upx * z1 - upy * z0;
|
|
2120
|
-
|
|
2121
|
-
if (!
|
|
3612
|
+
len5 = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
|
3613
|
+
if (!len5) {
|
|
2122
3614
|
x0 = 0;
|
|
2123
3615
|
x1 = 0;
|
|
2124
3616
|
x2 = 0;
|
|
2125
3617
|
} else {
|
|
2126
|
-
|
|
2127
|
-
x0 *=
|
|
2128
|
-
x1 *=
|
|
2129
|
-
x2 *=
|
|
3618
|
+
len5 = 1 / len5;
|
|
3619
|
+
x0 *= len5;
|
|
3620
|
+
x1 *= len5;
|
|
3621
|
+
x2 *= len5;
|
|
2130
3622
|
}
|
|
2131
3623
|
y0 = z1 * x2 - z2 * x1;
|
|
2132
3624
|
y1 = z2 * x0 - z0 * x2;
|
|
2133
3625
|
y2 = z0 * x1 - z1 * x0;
|
|
2134
|
-
|
|
2135
|
-
if (!
|
|
3626
|
+
len5 = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
|
|
3627
|
+
if (!len5) {
|
|
2136
3628
|
y0 = 0;
|
|
2137
3629
|
y1 = 0;
|
|
2138
3630
|
y2 = 0;
|
|
2139
3631
|
} else {
|
|
2140
|
-
|
|
2141
|
-
y0 *=
|
|
2142
|
-
y1 *=
|
|
2143
|
-
y2 *=
|
|
3632
|
+
len5 = 1 / len5;
|
|
3633
|
+
y0 *= len5;
|
|
3634
|
+
y1 *= len5;
|
|
3635
|
+
y2 *= len5;
|
|
2144
3636
|
}
|
|
2145
3637
|
out[0] = x0;
|
|
2146
3638
|
out[1] = y0;
|
|
@@ -2160,9 +3652,222 @@ function lookAt(out, eye, center, up) {
|
|
|
2160
3652
|
out[15] = 1;
|
|
2161
3653
|
return out;
|
|
2162
3654
|
}
|
|
3655
|
+
function targetTo(out, eye, target, up) {
|
|
3656
|
+
const eyex = eye[0];
|
|
3657
|
+
const eyey = eye[1];
|
|
3658
|
+
const eyez = eye[2];
|
|
3659
|
+
const upx = up[0];
|
|
3660
|
+
const upy = up[1];
|
|
3661
|
+
const upz = up[2];
|
|
3662
|
+
let z0 = eyex - target[0];
|
|
3663
|
+
let z1 = eyey - target[1];
|
|
3664
|
+
let z2 = eyez - target[2];
|
|
3665
|
+
let len5 = z0 * z0 + z1 * z1 + z2 * z2;
|
|
3666
|
+
if (len5 > 0) {
|
|
3667
|
+
len5 = 1 / Math.sqrt(len5);
|
|
3668
|
+
z0 *= len5;
|
|
3669
|
+
z1 *= len5;
|
|
3670
|
+
z2 *= len5;
|
|
3671
|
+
}
|
|
3672
|
+
let x0 = upy * z2 - upz * z1;
|
|
3673
|
+
let x1 = upz * z0 - upx * z2;
|
|
3674
|
+
let x2 = upx * z1 - upy * z0;
|
|
3675
|
+
len5 = x0 * x0 + x1 * x1 + x2 * x2;
|
|
3676
|
+
if (len5 > 0) {
|
|
3677
|
+
len5 = 1 / Math.sqrt(len5);
|
|
3678
|
+
x0 *= len5;
|
|
3679
|
+
x1 *= len5;
|
|
3680
|
+
x2 *= len5;
|
|
3681
|
+
}
|
|
3682
|
+
out[0] = x0;
|
|
3683
|
+
out[1] = x1;
|
|
3684
|
+
out[2] = x2;
|
|
3685
|
+
out[3] = 0;
|
|
3686
|
+
out[4] = z1 * x2 - z2 * x1;
|
|
3687
|
+
out[5] = z2 * x0 - z0 * x2;
|
|
3688
|
+
out[6] = z0 * x1 - z1 * x0;
|
|
3689
|
+
out[7] = 0;
|
|
3690
|
+
out[8] = z0;
|
|
3691
|
+
out[9] = z1;
|
|
3692
|
+
out[10] = z2;
|
|
3693
|
+
out[11] = 0;
|
|
3694
|
+
out[12] = eyex;
|
|
3695
|
+
out[13] = eyey;
|
|
3696
|
+
out[14] = eyez;
|
|
3697
|
+
out[15] = 1;
|
|
3698
|
+
return out;
|
|
3699
|
+
}
|
|
3700
|
+
function str4(a) {
|
|
3701
|
+
return `mat4(${a[0]}, ${a[1]}, ${a[2]}, ${a[3]}, ${a[4]}, ${a[5]}, ${a[6]}, ${a[7]}, ${a[8]}, ${a[9]}, ${a[10]}, ${a[11]}, ${a[12]}, ${a[13]}, ${a[14]}, ${a[15]})`;
|
|
3702
|
+
}
|
|
3703
|
+
function frob2(a) {
|
|
3704
|
+
return Math.sqrt(
|
|
3705
|
+
a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + a[6] * a[6] + a[7] * a[7] + a[8] * a[8] + a[9] * a[9] + a[10] * a[10] + a[11] * a[11] + a[12] * a[12] + a[13] * a[13] + a[14] * a[14] + a[15] * a[15]
|
|
3706
|
+
);
|
|
3707
|
+
}
|
|
3708
|
+
function add4(out, a, b) {
|
|
3709
|
+
out[0] = a[0] + b[0];
|
|
3710
|
+
out[1] = a[1] + b[1];
|
|
3711
|
+
out[2] = a[2] + b[2];
|
|
3712
|
+
out[3] = a[3] + b[3];
|
|
3713
|
+
out[4] = a[4] + b[4];
|
|
3714
|
+
out[5] = a[5] + b[5];
|
|
3715
|
+
out[6] = a[6] + b[6];
|
|
3716
|
+
out[7] = a[7] + b[7];
|
|
3717
|
+
out[8] = a[8] + b[8];
|
|
3718
|
+
out[9] = a[9] + b[9];
|
|
3719
|
+
out[10] = a[10] + b[10];
|
|
3720
|
+
out[11] = a[11] + b[11];
|
|
3721
|
+
out[12] = a[12] + b[12];
|
|
3722
|
+
out[13] = a[13] + b[13];
|
|
3723
|
+
out[14] = a[14] + b[14];
|
|
3724
|
+
out[15] = a[15] + b[15];
|
|
3725
|
+
return out;
|
|
3726
|
+
}
|
|
3727
|
+
function subtract4(out, a, b) {
|
|
3728
|
+
out[0] = a[0] - b[0];
|
|
3729
|
+
out[1] = a[1] - b[1];
|
|
3730
|
+
out[2] = a[2] - b[2];
|
|
3731
|
+
out[3] = a[3] - b[3];
|
|
3732
|
+
out[4] = a[4] - b[4];
|
|
3733
|
+
out[5] = a[5] - b[5];
|
|
3734
|
+
out[6] = a[6] - b[6];
|
|
3735
|
+
out[7] = a[7] - b[7];
|
|
3736
|
+
out[8] = a[8] - b[8];
|
|
3737
|
+
out[9] = a[9] - b[9];
|
|
3738
|
+
out[10] = a[10] - b[10];
|
|
3739
|
+
out[11] = a[11] - b[11];
|
|
3740
|
+
out[12] = a[12] - b[12];
|
|
3741
|
+
out[13] = a[13] - b[13];
|
|
3742
|
+
out[14] = a[14] - b[14];
|
|
3743
|
+
out[15] = a[15] - b[15];
|
|
3744
|
+
return out;
|
|
3745
|
+
}
|
|
3746
|
+
function multiplyScalar2(out, a, b) {
|
|
3747
|
+
out[0] = a[0] * b;
|
|
3748
|
+
out[1] = a[1] * b;
|
|
3749
|
+
out[2] = a[2] * b;
|
|
3750
|
+
out[3] = a[3] * b;
|
|
3751
|
+
out[4] = a[4] * b;
|
|
3752
|
+
out[5] = a[5] * b;
|
|
3753
|
+
out[6] = a[6] * b;
|
|
3754
|
+
out[7] = a[7] * b;
|
|
3755
|
+
out[8] = a[8] * b;
|
|
3756
|
+
out[9] = a[9] * b;
|
|
3757
|
+
out[10] = a[10] * b;
|
|
3758
|
+
out[11] = a[11] * b;
|
|
3759
|
+
out[12] = a[12] * b;
|
|
3760
|
+
out[13] = a[13] * b;
|
|
3761
|
+
out[14] = a[14] * b;
|
|
3762
|
+
out[15] = a[15] * b;
|
|
3763
|
+
return out;
|
|
3764
|
+
}
|
|
3765
|
+
function multiplyScalarAndAdd2(out, a, b, scale7) {
|
|
3766
|
+
out[0] = a[0] + b[0] * scale7;
|
|
3767
|
+
out[1] = a[1] + b[1] * scale7;
|
|
3768
|
+
out[2] = a[2] + b[2] * scale7;
|
|
3769
|
+
out[3] = a[3] + b[3] * scale7;
|
|
3770
|
+
out[4] = a[4] + b[4] * scale7;
|
|
3771
|
+
out[5] = a[5] + b[5] * scale7;
|
|
3772
|
+
out[6] = a[6] + b[6] * scale7;
|
|
3773
|
+
out[7] = a[7] + b[7] * scale7;
|
|
3774
|
+
out[8] = a[8] + b[8] * scale7;
|
|
3775
|
+
out[9] = a[9] + b[9] * scale7;
|
|
3776
|
+
out[10] = a[10] + b[10] * scale7;
|
|
3777
|
+
out[11] = a[11] + b[11] * scale7;
|
|
3778
|
+
out[12] = a[12] + b[12] * scale7;
|
|
3779
|
+
out[13] = a[13] + b[13] * scale7;
|
|
3780
|
+
out[14] = a[14] + b[14] * scale7;
|
|
3781
|
+
out[15] = a[15] + b[15] * scale7;
|
|
3782
|
+
return out;
|
|
3783
|
+
}
|
|
3784
|
+
function exactEquals5(a, b) {
|
|
3785
|
+
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] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];
|
|
3786
|
+
}
|
|
3787
|
+
function equals5(a, b) {
|
|
3788
|
+
const a0 = a[0];
|
|
3789
|
+
const a1 = a[1];
|
|
3790
|
+
const a2 = a[2];
|
|
3791
|
+
const a3 = a[3];
|
|
3792
|
+
const a4 = a[4];
|
|
3793
|
+
const a5 = a[5];
|
|
3794
|
+
const a6 = a[6];
|
|
3795
|
+
const a7 = a[7];
|
|
3796
|
+
const a8 = a[8];
|
|
3797
|
+
const a9 = a[9];
|
|
3798
|
+
const a10 = a[10];
|
|
3799
|
+
const a11 = a[11];
|
|
3800
|
+
const a12 = a[12];
|
|
3801
|
+
const a13 = a[13];
|
|
3802
|
+
const a14 = a[14];
|
|
3803
|
+
const a15 = a[15];
|
|
3804
|
+
const b0 = b[0];
|
|
3805
|
+
const b1 = b[1];
|
|
3806
|
+
const b2 = b[2];
|
|
3807
|
+
const b3 = b[3];
|
|
3808
|
+
const b4 = b[4];
|
|
3809
|
+
const b5 = b[5];
|
|
3810
|
+
const b6 = b[6];
|
|
3811
|
+
const b7 = b[7];
|
|
3812
|
+
const b8 = b[8];
|
|
3813
|
+
const b9 = b[9];
|
|
3814
|
+
const b10 = b[10];
|
|
3815
|
+
const b11 = b[11];
|
|
3816
|
+
const b12 = b[12];
|
|
3817
|
+
const b13 = b[13];
|
|
3818
|
+
const b14 = b[14];
|
|
3819
|
+
const b15 = b[15];
|
|
3820
|
+
return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= EPSILON * Math.max(1, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= EPSILON * Math.max(1, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= EPSILON * Math.max(1, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= EPSILON * Math.max(1, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= EPSILON * Math.max(1, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= EPSILON * Math.max(1, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= EPSILON * Math.max(1, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= EPSILON * Math.max(1, Math.abs(a15), Math.abs(b15));
|
|
3821
|
+
}
|
|
3822
|
+
var mul4 = multiply4;
|
|
3823
|
+
var sub4 = subtract4;
|
|
2163
3824
|
|
|
2164
|
-
// src/gl-matrix/vec4.
|
|
2165
|
-
|
|
3825
|
+
// src/gl-matrix/vec4.ts
|
|
3826
|
+
var vec4_exports = {};
|
|
3827
|
+
__export(vec4_exports, {
|
|
3828
|
+
add: () => add5,
|
|
3829
|
+
ceil: () => ceil3,
|
|
3830
|
+
clone: () => clone6,
|
|
3831
|
+
copy: () => copy5,
|
|
3832
|
+
create: () => create5,
|
|
3833
|
+
cross: () => cross3,
|
|
3834
|
+
dist: () => dist3,
|
|
3835
|
+
distance: () => distance3,
|
|
3836
|
+
div: () => div3,
|
|
3837
|
+
divide: () => divide3,
|
|
3838
|
+
dot: () => dot3,
|
|
3839
|
+
equals: () => equals6,
|
|
3840
|
+
exactEquals: () => exactEquals6,
|
|
3841
|
+
floor: () => floor3,
|
|
3842
|
+
forEach: () => forEach3,
|
|
3843
|
+
fromValues: () => fromValues5,
|
|
3844
|
+
inverse: () => inverse3,
|
|
3845
|
+
len: () => len3,
|
|
3846
|
+
length: () => length3,
|
|
3847
|
+
lerp: () => lerp4,
|
|
3848
|
+
max: () => max3,
|
|
3849
|
+
min: () => min3,
|
|
3850
|
+
mul: () => mul5,
|
|
3851
|
+
multiply: () => multiply5,
|
|
3852
|
+
negate: () => negate3,
|
|
3853
|
+
normalize: () => normalize3,
|
|
3854
|
+
random: () => random3,
|
|
3855
|
+
round: () => round5,
|
|
3856
|
+
scale: () => scale5,
|
|
3857
|
+
scaleAndAdd: () => scaleAndAdd3,
|
|
3858
|
+
set: () => set5,
|
|
3859
|
+
sqrDist: () => sqrDist3,
|
|
3860
|
+
sqrLen: () => sqrLen3,
|
|
3861
|
+
squaredDistance: () => squaredDistance3,
|
|
3862
|
+
squaredLength: () => squaredLength3,
|
|
3863
|
+
str: () => str5,
|
|
3864
|
+
sub: () => sub5,
|
|
3865
|
+
subtract: () => subtract5,
|
|
3866
|
+
transformMat4: () => transformMat43,
|
|
3867
|
+
transformQuat: () => transformQuat2,
|
|
3868
|
+
zero: () => zero3
|
|
3869
|
+
});
|
|
3870
|
+
function create5() {
|
|
2166
3871
|
const out = new ARRAY_TYPE(4);
|
|
2167
3872
|
if (ARRAY_TYPE != Float32Array) {
|
|
2168
3873
|
out[0] = 0;
|
|
@@ -2172,53 +3877,191 @@ function create4() {
|
|
|
2172
3877
|
}
|
|
2173
3878
|
return out;
|
|
2174
3879
|
}
|
|
2175
|
-
function
|
|
3880
|
+
function clone6(a) {
|
|
3881
|
+
const out = new ARRAY_TYPE(4);
|
|
3882
|
+
out[0] = a[0];
|
|
3883
|
+
out[1] = a[1];
|
|
3884
|
+
out[2] = a[2];
|
|
3885
|
+
out[3] = a[3];
|
|
3886
|
+
return out;
|
|
3887
|
+
}
|
|
3888
|
+
function fromValues5(x, y, z, w) {
|
|
3889
|
+
const out = new ARRAY_TYPE(4);
|
|
3890
|
+
out[0] = x;
|
|
3891
|
+
out[1] = y;
|
|
3892
|
+
out[2] = z;
|
|
3893
|
+
out[3] = w;
|
|
3894
|
+
return out;
|
|
3895
|
+
}
|
|
3896
|
+
function copy5(out, a) {
|
|
3897
|
+
out[0] = a[0];
|
|
3898
|
+
out[1] = a[1];
|
|
3899
|
+
out[2] = a[2];
|
|
3900
|
+
out[3] = a[3];
|
|
3901
|
+
return out;
|
|
3902
|
+
}
|
|
3903
|
+
function set5(out, x, y, z, w) {
|
|
3904
|
+
out[0] = x;
|
|
3905
|
+
out[1] = y;
|
|
3906
|
+
out[2] = z;
|
|
3907
|
+
out[3] = w;
|
|
3908
|
+
return out;
|
|
3909
|
+
}
|
|
3910
|
+
function add5(out, a, b) {
|
|
2176
3911
|
out[0] = a[0] + b[0];
|
|
2177
3912
|
out[1] = a[1] + b[1];
|
|
2178
3913
|
out[2] = a[2] + b[2];
|
|
2179
3914
|
out[3] = a[3] + b[3];
|
|
2180
3915
|
return out;
|
|
2181
3916
|
}
|
|
2182
|
-
function
|
|
3917
|
+
function subtract5(out, a, b) {
|
|
3918
|
+
out[0] = a[0] - b[0];
|
|
3919
|
+
out[1] = a[1] - b[1];
|
|
3920
|
+
out[2] = a[2] - b[2];
|
|
3921
|
+
out[3] = a[3] - b[3];
|
|
3922
|
+
return out;
|
|
3923
|
+
}
|
|
3924
|
+
function multiply5(out, a, b) {
|
|
3925
|
+
out[0] = a[0] * b[0];
|
|
3926
|
+
out[1] = a[1] * b[1];
|
|
3927
|
+
out[2] = a[2] * b[2];
|
|
3928
|
+
out[3] = a[3] * b[3];
|
|
3929
|
+
return out;
|
|
3930
|
+
}
|
|
3931
|
+
function divide3(out, a, b) {
|
|
3932
|
+
out[0] = a[0] / b[0];
|
|
3933
|
+
out[1] = a[1] / b[1];
|
|
3934
|
+
out[2] = a[2] / b[2];
|
|
3935
|
+
out[3] = a[3] / b[3];
|
|
3936
|
+
return out;
|
|
3937
|
+
}
|
|
3938
|
+
function ceil3(out, a) {
|
|
3939
|
+
out[0] = Math.ceil(a[0]);
|
|
3940
|
+
out[1] = Math.ceil(a[1]);
|
|
3941
|
+
out[2] = Math.ceil(a[2]);
|
|
3942
|
+
out[3] = Math.ceil(a[3]);
|
|
3943
|
+
return out;
|
|
3944
|
+
}
|
|
3945
|
+
function floor3(out, a) {
|
|
3946
|
+
out[0] = Math.floor(a[0]);
|
|
3947
|
+
out[1] = Math.floor(a[1]);
|
|
3948
|
+
out[2] = Math.floor(a[2]);
|
|
3949
|
+
out[3] = Math.floor(a[3]);
|
|
3950
|
+
return out;
|
|
3951
|
+
}
|
|
3952
|
+
function min3(out, a, b) {
|
|
3953
|
+
out[0] = Math.min(a[0], b[0]);
|
|
3954
|
+
out[1] = Math.min(a[1], b[1]);
|
|
3955
|
+
out[2] = Math.min(a[2], b[2]);
|
|
3956
|
+
out[3] = Math.min(a[3], b[3]);
|
|
3957
|
+
return out;
|
|
3958
|
+
}
|
|
3959
|
+
function max3(out, a, b) {
|
|
3960
|
+
out[0] = Math.max(a[0], b[0]);
|
|
3961
|
+
out[1] = Math.max(a[1], b[1]);
|
|
3962
|
+
out[2] = Math.max(a[2], b[2]);
|
|
3963
|
+
out[3] = Math.max(a[3], b[3]);
|
|
3964
|
+
return out;
|
|
3965
|
+
}
|
|
3966
|
+
function round5(out, a) {
|
|
3967
|
+
out[0] = round2(a[0]);
|
|
3968
|
+
out[1] = round2(a[1]);
|
|
3969
|
+
out[2] = round2(a[2]);
|
|
3970
|
+
out[3] = round2(a[3]);
|
|
3971
|
+
return out;
|
|
3972
|
+
}
|
|
3973
|
+
function scale5(out, a, b) {
|
|
2183
3974
|
out[0] = a[0] * b;
|
|
2184
3975
|
out[1] = a[1] * b;
|
|
2185
3976
|
out[2] = a[2] * b;
|
|
2186
3977
|
out[3] = a[3] * b;
|
|
2187
3978
|
return out;
|
|
2188
3979
|
}
|
|
2189
|
-
function
|
|
3980
|
+
function scaleAndAdd3(out, a, b, scale7) {
|
|
3981
|
+
out[0] = a[0] + b[0] * scale7;
|
|
3982
|
+
out[1] = a[1] + b[1] * scale7;
|
|
3983
|
+
out[2] = a[2] + b[2] * scale7;
|
|
3984
|
+
out[3] = a[3] + b[3] * scale7;
|
|
3985
|
+
return out;
|
|
3986
|
+
}
|
|
3987
|
+
function distance3(a, b) {
|
|
3988
|
+
const x = b[0] - a[0];
|
|
3989
|
+
const y = b[1] - a[1];
|
|
3990
|
+
const z = b[2] - a[2];
|
|
3991
|
+
const w = b[3] - a[3];
|
|
3992
|
+
return Math.sqrt(x * x + y * y + z * z + w * w);
|
|
3993
|
+
}
|
|
3994
|
+
function squaredDistance3(a, b) {
|
|
3995
|
+
const x = b[0] - a[0];
|
|
3996
|
+
const y = b[1] - a[1];
|
|
3997
|
+
const z = b[2] - a[2];
|
|
3998
|
+
const w = b[3] - a[3];
|
|
3999
|
+
return x * x + y * y + z * z + w * w;
|
|
4000
|
+
}
|
|
4001
|
+
function length3(a) {
|
|
2190
4002
|
const x = a[0];
|
|
2191
4003
|
const y = a[1];
|
|
2192
4004
|
const z = a[2];
|
|
2193
4005
|
const w = a[3];
|
|
2194
4006
|
return Math.sqrt(x * x + y * y + z * z + w * w);
|
|
2195
4007
|
}
|
|
2196
|
-
function
|
|
4008
|
+
function squaredLength3(a) {
|
|
2197
4009
|
const x = a[0];
|
|
2198
4010
|
const y = a[1];
|
|
2199
4011
|
const z = a[2];
|
|
2200
4012
|
const w = a[3];
|
|
2201
4013
|
return x * x + y * y + z * z + w * w;
|
|
2202
4014
|
}
|
|
2203
|
-
function
|
|
4015
|
+
function negate3(out, a) {
|
|
4016
|
+
out[0] = -a[0];
|
|
4017
|
+
out[1] = -a[1];
|
|
4018
|
+
out[2] = -a[2];
|
|
4019
|
+
out[3] = -a[3];
|
|
4020
|
+
return out;
|
|
4021
|
+
}
|
|
4022
|
+
function inverse3(out, a) {
|
|
4023
|
+
out[0] = 1 / a[0];
|
|
4024
|
+
out[1] = 1 / a[1];
|
|
4025
|
+
out[2] = 1 / a[2];
|
|
4026
|
+
out[3] = 1 / a[3];
|
|
4027
|
+
return out;
|
|
4028
|
+
}
|
|
4029
|
+
function normalize3(out, a) {
|
|
2204
4030
|
const x = a[0];
|
|
2205
4031
|
const y = a[1];
|
|
2206
4032
|
const z = a[2];
|
|
2207
4033
|
const w = a[3];
|
|
2208
|
-
let
|
|
2209
|
-
if (
|
|
2210
|
-
|
|
2211
|
-
}
|
|
2212
|
-
out[0] = x *
|
|
2213
|
-
out[1] = y *
|
|
2214
|
-
out[2] = z *
|
|
2215
|
-
out[3] = w *
|
|
4034
|
+
let len5 = x * x + y * y + z * z + w * w;
|
|
4035
|
+
if (len5 > 0) {
|
|
4036
|
+
len5 = 1 / Math.sqrt(len5);
|
|
4037
|
+
}
|
|
4038
|
+
out[0] = x * len5;
|
|
4039
|
+
out[1] = y * len5;
|
|
4040
|
+
out[2] = z * len5;
|
|
4041
|
+
out[3] = w * len5;
|
|
2216
4042
|
return out;
|
|
2217
4043
|
}
|
|
2218
|
-
function
|
|
4044
|
+
function dot3(a, b) {
|
|
2219
4045
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
|
|
2220
4046
|
}
|
|
2221
|
-
function
|
|
4047
|
+
function cross3(out, u, v, w) {
|
|
4048
|
+
const A = v[0] * w[1] - v[1] * w[0];
|
|
4049
|
+
const B = v[0] * w[2] - v[2] * w[0];
|
|
4050
|
+
const C = v[0] * w[3] - v[3] * w[0];
|
|
4051
|
+
const D = v[1] * w[2] - v[2] * w[1];
|
|
4052
|
+
const E = v[1] * w[3] - v[3] * w[1];
|
|
4053
|
+
const F = v[2] * w[3] - v[3] * w[2];
|
|
4054
|
+
const G = u[0];
|
|
4055
|
+
const H = u[1];
|
|
4056
|
+
const I = u[2];
|
|
4057
|
+
const J = u[3];
|
|
4058
|
+
out[0] = H * F - I * E + J * D;
|
|
4059
|
+
out[1] = -(G * F) + I * C - J * B;
|
|
4060
|
+
out[2] = G * E - H * C + J * A;
|
|
4061
|
+
out[3] = -(G * D) + H * B - I * A;
|
|
4062
|
+
return out;
|
|
4063
|
+
}
|
|
4064
|
+
function lerp4(out, a, b, t) {
|
|
2222
4065
|
const ax = a[0];
|
|
2223
4066
|
const ay = a[1];
|
|
2224
4067
|
const az = a[2];
|
|
@@ -2229,6 +4072,31 @@ function lerp2(out, a, b, t) {
|
|
|
2229
4072
|
out[3] = aw + t * (b[3] - aw);
|
|
2230
4073
|
return out;
|
|
2231
4074
|
}
|
|
4075
|
+
function random3(out, scale7) {
|
|
4076
|
+
scale7 = scale7 === void 0 ? 1 : scale7;
|
|
4077
|
+
let v1;
|
|
4078
|
+
let v2;
|
|
4079
|
+
let v3;
|
|
4080
|
+
let v4;
|
|
4081
|
+
let s1;
|
|
4082
|
+
let s2;
|
|
4083
|
+
do {
|
|
4084
|
+
v1 = RANDOM() * 2 - 1;
|
|
4085
|
+
v2 = RANDOM() * 2 - 1;
|
|
4086
|
+
s1 = v1 * v1 + v2 * v2;
|
|
4087
|
+
} while (s1 >= 1);
|
|
4088
|
+
do {
|
|
4089
|
+
v3 = RANDOM() * 2 - 1;
|
|
4090
|
+
v4 = RANDOM() * 2 - 1;
|
|
4091
|
+
s2 = v3 * v3 + v4 * v4;
|
|
4092
|
+
} while (s2 >= 1);
|
|
4093
|
+
const d = Math.sqrt((1 - s1) / s2);
|
|
4094
|
+
out[0] = scale7 * v1;
|
|
4095
|
+
out[1] = scale7 * v2;
|
|
4096
|
+
out[2] = scale7 * v3 * d;
|
|
4097
|
+
out[3] = scale7 * v4 * d;
|
|
4098
|
+
return out;
|
|
4099
|
+
}
|
|
2232
4100
|
function transformMat43(out, a, m) {
|
|
2233
4101
|
const x = a[0];
|
|
2234
4102
|
const y = a[1];
|
|
@@ -2258,8 +4126,39 @@ function transformQuat2(out, a, q) {
|
|
|
2258
4126
|
out[3] = a[3];
|
|
2259
4127
|
return out;
|
|
2260
4128
|
}
|
|
4129
|
+
function zero3(out) {
|
|
4130
|
+
out[0] = 0;
|
|
4131
|
+
out[1] = 0;
|
|
4132
|
+
out[2] = 0;
|
|
4133
|
+
out[3] = 0;
|
|
4134
|
+
return out;
|
|
4135
|
+
}
|
|
4136
|
+
function str5(a) {
|
|
4137
|
+
return `vec4(${a[0]}, ${a[1]}, ${a[2]}, ${a[3]})`;
|
|
4138
|
+
}
|
|
4139
|
+
function exactEquals6(a, b) {
|
|
4140
|
+
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
|
|
4141
|
+
}
|
|
4142
|
+
function equals6(a, b) {
|
|
4143
|
+
const a0 = a[0];
|
|
4144
|
+
const a1 = a[1];
|
|
4145
|
+
const a2 = a[2];
|
|
4146
|
+
const a3 = a[3];
|
|
4147
|
+
const b0 = b[0];
|
|
4148
|
+
const b1 = b[1];
|
|
4149
|
+
const b2 = b[2];
|
|
4150
|
+
const b3 = b[3];
|
|
4151
|
+
return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3));
|
|
4152
|
+
}
|
|
4153
|
+
var sub5 = subtract5;
|
|
4154
|
+
var mul5 = multiply5;
|
|
4155
|
+
var div3 = divide3;
|
|
4156
|
+
var dist3 = distance3;
|
|
4157
|
+
var sqrDist3 = squaredDistance3;
|
|
4158
|
+
var len3 = length3;
|
|
4159
|
+
var sqrLen3 = squaredLength3;
|
|
2261
4160
|
var forEach3 = function() {
|
|
2262
|
-
const vec =
|
|
4161
|
+
const vec = create5();
|
|
2263
4162
|
return function(a, stride, offset, count, fn, arg) {
|
|
2264
4163
|
let i;
|
|
2265
4164
|
let l;
|
|
@@ -2421,7 +4320,7 @@ var Matrix4 = class extends Matrix {
|
|
|
2421
4320
|
return this.check();
|
|
2422
4321
|
}
|
|
2423
4322
|
fromQuaternion(quaternion) {
|
|
2424
|
-
|
|
4323
|
+
fromQuat3(this, quaternion);
|
|
2425
4324
|
return this.check();
|
|
2426
4325
|
}
|
|
2427
4326
|
frustum(view) {
|
|
@@ -2488,10 +4387,10 @@ var Matrix4 = class extends Matrix {
|
|
|
2488
4387
|
getRotation(result, scaleResult) {
|
|
2489
4388
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
2490
4389
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
2491
|
-
const
|
|
2492
|
-
const inverseScale0 = 1 /
|
|
2493
|
-
const inverseScale1 = 1 /
|
|
2494
|
-
const inverseScale2 = 1 /
|
|
4390
|
+
const scale7 = this.getScale(scaleResult);
|
|
4391
|
+
const inverseScale0 = 1 / scale7[0];
|
|
4392
|
+
const inverseScale1 = 1 / scale7[1];
|
|
4393
|
+
const inverseScale2 = 1 / scale7[2];
|
|
2495
4394
|
result[0] = this[0] * inverseScale0;
|
|
2496
4395
|
result[1] = this[1] * inverseScale1;
|
|
2497
4396
|
result[2] = this[2] * inverseScale2;
|
|
@@ -2513,10 +4412,10 @@ var Matrix4 = class extends Matrix {
|
|
|
2513
4412
|
getRotationMatrix3(result, scaleResult) {
|
|
2514
4413
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
2515
4414
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
2516
|
-
const
|
|
2517
|
-
const inverseScale0 = 1 /
|
|
2518
|
-
const inverseScale1 = 1 /
|
|
2519
|
-
const inverseScale2 = 1 /
|
|
4415
|
+
const scale7 = this.getScale(scaleResult);
|
|
4416
|
+
const inverseScale0 = 1 / scale7[0];
|
|
4417
|
+
const inverseScale1 = 1 / scale7[1];
|
|
4418
|
+
const inverseScale2 = 1 / scale7[2];
|
|
2520
4419
|
result[0] = this[0] * inverseScale0;
|
|
2521
4420
|
result[1] = this[1] * inverseScale1;
|
|
2522
4421
|
result[2] = this[2] * inverseScale2;
|
|
@@ -2537,11 +4436,11 @@ var Matrix4 = class extends Matrix {
|
|
|
2537
4436
|
return this.check();
|
|
2538
4437
|
}
|
|
2539
4438
|
multiplyLeft(a) {
|
|
2540
|
-
|
|
4439
|
+
multiply4(this, a, this);
|
|
2541
4440
|
return this.check();
|
|
2542
4441
|
}
|
|
2543
4442
|
multiplyRight(a) {
|
|
2544
|
-
|
|
4443
|
+
multiply4(this, this, a);
|
|
2545
4444
|
return this.check();
|
|
2546
4445
|
}
|
|
2547
4446
|
rotateX(radians2) {
|
|
@@ -2560,11 +4459,11 @@ var Matrix4 = class extends Matrix {
|
|
|
2560
4459
|
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
|
|
2561
4460
|
}
|
|
2562
4461
|
rotateAxis(radians2, axis) {
|
|
2563
|
-
|
|
4462
|
+
rotate3(this, this, radians2, axis);
|
|
2564
4463
|
return this.check();
|
|
2565
4464
|
}
|
|
2566
4465
|
scale(factor) {
|
|
2567
|
-
|
|
4466
|
+
scale4(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
|
|
2568
4467
|
return this.check();
|
|
2569
4468
|
}
|
|
2570
4469
|
translate(vector) {
|
|
@@ -2580,9 +4479,9 @@ var Matrix4 = class extends Matrix {
|
|
|
2580
4479
|
return this.transformAsPoint(vector, result);
|
|
2581
4480
|
}
|
|
2582
4481
|
transformAsPoint(vector, result) {
|
|
2583
|
-
const { length:
|
|
4482
|
+
const { length: length5 } = vector;
|
|
2584
4483
|
let out;
|
|
2585
|
-
switch (
|
|
4484
|
+
switch (length5) {
|
|
2586
4485
|
case 2:
|
|
2587
4486
|
out = transformMat4(result || [-0, -0], vector, this);
|
|
2588
4487
|
break;
|
|
@@ -2675,7 +4574,47 @@ function computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, n
|
|
|
2675
4574
|
}
|
|
2676
4575
|
|
|
2677
4576
|
// src/gl-matrix/quat.ts
|
|
2678
|
-
|
|
4577
|
+
var quat_exports = {};
|
|
4578
|
+
__export(quat_exports, {
|
|
4579
|
+
add: () => add6,
|
|
4580
|
+
calculateW: () => calculateW,
|
|
4581
|
+
clone: () => clone7,
|
|
4582
|
+
conjugate: () => conjugate,
|
|
4583
|
+
copy: () => copy6,
|
|
4584
|
+
create: () => create6,
|
|
4585
|
+
dot: () => dot4,
|
|
4586
|
+
equals: () => equals7,
|
|
4587
|
+
exactEquals: () => exactEquals7,
|
|
4588
|
+
exp: () => exp,
|
|
4589
|
+
fromMat3: () => fromMat3,
|
|
4590
|
+
fromValues: () => fromValues6,
|
|
4591
|
+
getAngle: () => getAngle,
|
|
4592
|
+
getAxisAngle: () => getAxisAngle,
|
|
4593
|
+
identity: () => identity3,
|
|
4594
|
+
invert: () => invert3,
|
|
4595
|
+
len: () => len4,
|
|
4596
|
+
length: () => length4,
|
|
4597
|
+
lerp: () => lerp5,
|
|
4598
|
+
ln: () => ln,
|
|
4599
|
+
mul: () => mul6,
|
|
4600
|
+
multiply: () => multiply6,
|
|
4601
|
+
normalize: () => normalize4,
|
|
4602
|
+
pow: () => pow,
|
|
4603
|
+
rotateX: () => rotateX3,
|
|
4604
|
+
rotateY: () => rotateY3,
|
|
4605
|
+
rotateZ: () => rotateZ3,
|
|
4606
|
+
rotationTo: () => rotationTo,
|
|
4607
|
+
scale: () => scale6,
|
|
4608
|
+
set: () => set6,
|
|
4609
|
+
setAxes: () => setAxes,
|
|
4610
|
+
setAxisAngle: () => setAxisAngle,
|
|
4611
|
+
slerp: () => slerp2,
|
|
4612
|
+
sqlerp: () => sqlerp,
|
|
4613
|
+
sqrLen: () => sqrLen4,
|
|
4614
|
+
squaredLength: () => squaredLength4,
|
|
4615
|
+
str: () => str6
|
|
4616
|
+
});
|
|
4617
|
+
function create6() {
|
|
2679
4618
|
const out = new ARRAY_TYPE(4);
|
|
2680
4619
|
if (ARRAY_TYPE != Float32Array) {
|
|
2681
4620
|
out[0] = 0;
|
|
@@ -2685,7 +4624,7 @@ function create5() {
|
|
|
2685
4624
|
out[3] = 1;
|
|
2686
4625
|
return out;
|
|
2687
4626
|
}
|
|
2688
|
-
function
|
|
4627
|
+
function identity3(out) {
|
|
2689
4628
|
out[0] = 0;
|
|
2690
4629
|
out[1] = 0;
|
|
2691
4630
|
out[2] = 0;
|
|
@@ -2701,7 +4640,25 @@ function setAxisAngle(out, axis, rad) {
|
|
|
2701
4640
|
out[3] = Math.cos(rad);
|
|
2702
4641
|
return out;
|
|
2703
4642
|
}
|
|
2704
|
-
function
|
|
4643
|
+
function getAxisAngle(out_axis, q) {
|
|
4644
|
+
const rad = Math.acos(q[3]) * 2;
|
|
4645
|
+
const s = Math.sin(rad / 2);
|
|
4646
|
+
if (s > EPSILON) {
|
|
4647
|
+
out_axis[0] = q[0] / s;
|
|
4648
|
+
out_axis[1] = q[1] / s;
|
|
4649
|
+
out_axis[2] = q[2] / s;
|
|
4650
|
+
} else {
|
|
4651
|
+
out_axis[0] = 1;
|
|
4652
|
+
out_axis[1] = 0;
|
|
4653
|
+
out_axis[2] = 0;
|
|
4654
|
+
}
|
|
4655
|
+
return rad;
|
|
4656
|
+
}
|
|
4657
|
+
function getAngle(a, b) {
|
|
4658
|
+
const dotproduct = dot4(a, b);
|
|
4659
|
+
return Math.acos(2 * dotproduct * dotproduct - 1);
|
|
4660
|
+
}
|
|
4661
|
+
function multiply6(out, a, b) {
|
|
2705
4662
|
const ax = a[0];
|
|
2706
4663
|
const ay = a[1];
|
|
2707
4664
|
const az = a[2];
|
|
@@ -2768,7 +4725,40 @@ function calculateW(out, a) {
|
|
|
2768
4725
|
out[3] = Math.sqrt(Math.abs(1 - x * x - y * y - z * z));
|
|
2769
4726
|
return out;
|
|
2770
4727
|
}
|
|
2771
|
-
function
|
|
4728
|
+
function exp(out, a) {
|
|
4729
|
+
const x = a[0];
|
|
4730
|
+
const y = a[1];
|
|
4731
|
+
const z = a[2];
|
|
4732
|
+
const w = a[3];
|
|
4733
|
+
const r = Math.sqrt(x * x + y * y + z * z);
|
|
4734
|
+
const et = Math.exp(w);
|
|
4735
|
+
const s = r > 0 ? et * Math.sin(r) / r : 0;
|
|
4736
|
+
out[0] = x * s;
|
|
4737
|
+
out[1] = y * s;
|
|
4738
|
+
out[2] = z * s;
|
|
4739
|
+
out[3] = et * Math.cos(r);
|
|
4740
|
+
return out;
|
|
4741
|
+
}
|
|
4742
|
+
function ln(out, a) {
|
|
4743
|
+
const x = a[0];
|
|
4744
|
+
const y = a[1];
|
|
4745
|
+
const z = a[2];
|
|
4746
|
+
const w = a[3];
|
|
4747
|
+
const r = Math.sqrt(x * x + y * y + z * z);
|
|
4748
|
+
const t = r > 0 ? Math.atan2(r, w) / r : 0;
|
|
4749
|
+
out[0] = x * t;
|
|
4750
|
+
out[1] = y * t;
|
|
4751
|
+
out[2] = z * t;
|
|
4752
|
+
out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w);
|
|
4753
|
+
return out;
|
|
4754
|
+
}
|
|
4755
|
+
function pow(out, a, b) {
|
|
4756
|
+
ln(out, a);
|
|
4757
|
+
scale6(out, out, b);
|
|
4758
|
+
exp(out, out);
|
|
4759
|
+
return out;
|
|
4760
|
+
}
|
|
4761
|
+
function slerp2(out, a, b, t) {
|
|
2772
4762
|
const ax = a[0];
|
|
2773
4763
|
const ay = a[1];
|
|
2774
4764
|
const az = a[2];
|
|
@@ -2810,8 +4800,8 @@ function invert3(out, a) {
|
|
|
2810
4800
|
const a1 = a[1];
|
|
2811
4801
|
const a2 = a[2];
|
|
2812
4802
|
const a3 = a[3];
|
|
2813
|
-
const
|
|
2814
|
-
const invDot =
|
|
4803
|
+
const dot5 = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;
|
|
4804
|
+
const invDot = dot5 ? 1 / dot5 : 0;
|
|
2815
4805
|
out[0] = -a0 * invDot;
|
|
2816
4806
|
out[1] = -a1 * invDot;
|
|
2817
4807
|
out[2] = -a2 * invDot;
|
|
@@ -2852,48 +4842,62 @@ function fromMat3(out, m) {
|
|
|
2852
4842
|
}
|
|
2853
4843
|
return out;
|
|
2854
4844
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
var
|
|
2859
|
-
var
|
|
2860
|
-
var
|
|
2861
|
-
var
|
|
4845
|
+
function str6(a) {
|
|
4846
|
+
return `quat(${a[0]}, ${a[1]}, ${a[2]}, ${a[3]})`;
|
|
4847
|
+
}
|
|
4848
|
+
var clone7 = clone6;
|
|
4849
|
+
var fromValues6 = fromValues5;
|
|
4850
|
+
var copy6 = copy5;
|
|
4851
|
+
var set6 = set5;
|
|
4852
|
+
var add6 = add5;
|
|
4853
|
+
var mul6 = multiply6;
|
|
4854
|
+
var scale6 = scale5;
|
|
4855
|
+
var dot4 = dot3;
|
|
4856
|
+
var lerp5 = lerp4;
|
|
4857
|
+
var length4 = length3;
|
|
4858
|
+
var len4 = length4;
|
|
4859
|
+
var squaredLength4 = squaredLength3;
|
|
4860
|
+
var sqrLen4 = squaredLength4;
|
|
4861
|
+
var normalize4 = normalize3;
|
|
4862
|
+
var exactEquals7 = exactEquals6;
|
|
4863
|
+
function equals7(a, b) {
|
|
4864
|
+
return Math.abs(dot3(a, b)) >= 1 - EPSILON;
|
|
4865
|
+
}
|
|
2862
4866
|
var rotationTo = function() {
|
|
2863
4867
|
const tmpvec3 = create2();
|
|
2864
|
-
const xUnitVec3 =
|
|
2865
|
-
const yUnitVec3 =
|
|
4868
|
+
const xUnitVec3 = fromValues2(1, 0, 0);
|
|
4869
|
+
const yUnitVec3 = fromValues2(0, 1, 0);
|
|
2866
4870
|
return function(out, a, b) {
|
|
2867
|
-
const
|
|
2868
|
-
if (
|
|
2869
|
-
|
|
2870
|
-
if (
|
|
2871
|
-
|
|
2872
|
-
|
|
4871
|
+
const dot5 = dot2(a, b);
|
|
4872
|
+
if (dot5 < -0.999999) {
|
|
4873
|
+
cross2(tmpvec3, xUnitVec3, a);
|
|
4874
|
+
if (len2(tmpvec3) < 1e-6)
|
|
4875
|
+
cross2(tmpvec3, yUnitVec3, a);
|
|
4876
|
+
normalize2(tmpvec3, tmpvec3);
|
|
2873
4877
|
setAxisAngle(out, tmpvec3, Math.PI);
|
|
2874
4878
|
return out;
|
|
2875
|
-
} else if (
|
|
4879
|
+
} else if (dot5 > 0.999999) {
|
|
2876
4880
|
out[0] = 0;
|
|
2877
4881
|
out[1] = 0;
|
|
2878
4882
|
out[2] = 0;
|
|
2879
4883
|
out[3] = 1;
|
|
2880
4884
|
return out;
|
|
2881
4885
|
}
|
|
2882
|
-
|
|
4886
|
+
cross2(tmpvec3, a, b);
|
|
2883
4887
|
out[0] = tmpvec3[0];
|
|
2884
4888
|
out[1] = tmpvec3[1];
|
|
2885
4889
|
out[2] = tmpvec3[2];
|
|
2886
|
-
out[3] = 1 +
|
|
2887
|
-
return
|
|
4890
|
+
out[3] = 1 + dot5;
|
|
4891
|
+
return normalize4(out, out);
|
|
2888
4892
|
};
|
|
2889
4893
|
}();
|
|
2890
4894
|
var sqlerp = function() {
|
|
2891
|
-
const temp1 =
|
|
2892
|
-
const temp2 =
|
|
4895
|
+
const temp1 = create6();
|
|
4896
|
+
const temp2 = create6();
|
|
2893
4897
|
return function(out, a, b, c, d, t) {
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
4898
|
+
slerp2(temp1, a, d, t);
|
|
4899
|
+
slerp2(temp2, b, c, t);
|
|
4900
|
+
slerp2(out, temp1, temp2, 2 * t * (1 - t));
|
|
2897
4901
|
return out;
|
|
2898
4902
|
};
|
|
2899
4903
|
}();
|
|
@@ -2909,7 +4913,7 @@ var setAxes = function() {
|
|
|
2909
4913
|
matr[2] = -view[0];
|
|
2910
4914
|
matr[5] = -view[1];
|
|
2911
4915
|
matr[8] = -view[2];
|
|
2912
|
-
return
|
|
4916
|
+
return normalize4(out, fromMat3(out, matr));
|
|
2913
4917
|
};
|
|
2914
4918
|
}();
|
|
2915
4919
|
|
|
@@ -2954,7 +4958,7 @@ var Quaternion = class extends MathArray {
|
|
|
2954
4958
|
return this.check();
|
|
2955
4959
|
}
|
|
2956
4960
|
identity() {
|
|
2957
|
-
|
|
4961
|
+
identity3(this);
|
|
2958
4962
|
return this.check();
|
|
2959
4963
|
}
|
|
2960
4964
|
setAxisAngle(axis, rad) {
|
|
@@ -2988,20 +4992,20 @@ var Quaternion = class extends MathArray {
|
|
|
2988
4992
|
this[3] = checkNumber(value);
|
|
2989
4993
|
}
|
|
2990
4994
|
len() {
|
|
2991
|
-
return
|
|
4995
|
+
return length4(this);
|
|
2992
4996
|
}
|
|
2993
4997
|
lengthSquared() {
|
|
2994
|
-
return
|
|
4998
|
+
return squaredLength4(this);
|
|
2995
4999
|
}
|
|
2996
5000
|
dot(a) {
|
|
2997
|
-
return
|
|
5001
|
+
return dot4(this, a);
|
|
2998
5002
|
}
|
|
2999
5003
|
rotationTo(vectorA, vectorB) {
|
|
3000
5004
|
rotationTo(this, vectorA, vectorB);
|
|
3001
5005
|
return this.check();
|
|
3002
5006
|
}
|
|
3003
5007
|
add(a) {
|
|
3004
|
-
|
|
5008
|
+
add6(this, this, a);
|
|
3005
5009
|
return this.check();
|
|
3006
5010
|
}
|
|
3007
5011
|
calculateW() {
|
|
@@ -3020,25 +5024,25 @@ var Quaternion = class extends MathArray {
|
|
|
3020
5024
|
if (t === void 0) {
|
|
3021
5025
|
return this.lerp(this, a, b);
|
|
3022
5026
|
}
|
|
3023
|
-
|
|
5027
|
+
lerp5(this, a, b, t);
|
|
3024
5028
|
return this.check();
|
|
3025
5029
|
}
|
|
3026
5030
|
multiplyRight(a) {
|
|
3027
|
-
|
|
5031
|
+
multiply6(this, this, a);
|
|
3028
5032
|
return this.check();
|
|
3029
5033
|
}
|
|
3030
5034
|
multiplyLeft(a) {
|
|
3031
|
-
|
|
5035
|
+
multiply6(this, a, this);
|
|
3032
5036
|
return this.check();
|
|
3033
5037
|
}
|
|
3034
5038
|
normalize() {
|
|
3035
|
-
const
|
|
3036
|
-
const l =
|
|
5039
|
+
const length5 = this.len();
|
|
5040
|
+
const l = length5 > 0 ? 1 / length5 : 0;
|
|
3037
5041
|
this[0] = this[0] * l;
|
|
3038
5042
|
this[1] = this[1] * l;
|
|
3039
5043
|
this[2] = this[2] * l;
|
|
3040
5044
|
this[3] = this[3] * l;
|
|
3041
|
-
if (
|
|
5045
|
+
if (length5 === 0) {
|
|
3042
5046
|
this[3] = 1;
|
|
3043
5047
|
}
|
|
3044
5048
|
return this.check();
|
|
@@ -3056,7 +5060,7 @@ var Quaternion = class extends MathArray {
|
|
|
3056
5060
|
return this.check();
|
|
3057
5061
|
}
|
|
3058
5062
|
scale(b) {
|
|
3059
|
-
|
|
5063
|
+
scale6(this, this, b);
|
|
3060
5064
|
return this.check();
|
|
3061
5065
|
}
|
|
3062
5066
|
slerp(arg0, arg1, arg2) {
|
|
@@ -3081,7 +5085,7 @@ var Quaternion = class extends MathArray {
|
|
|
3081
5085
|
target = arg1;
|
|
3082
5086
|
ratio = arg2;
|
|
3083
5087
|
}
|
|
3084
|
-
|
|
5088
|
+
slerp2(this, start, target, ratio);
|
|
3085
5089
|
return this.check();
|
|
3086
5090
|
}
|
|
3087
5091
|
transformVector4(vector, result = new Vector4()) {
|
|
@@ -3189,7 +5193,7 @@ var SphericalCoordinates = class {
|
|
|
3189
5193
|
return this.check();
|
|
3190
5194
|
}
|
|
3191
5195
|
fromVector3(v) {
|
|
3192
|
-
this.radius =
|
|
5196
|
+
this.radius = length2(v);
|
|
3193
5197
|
if (this.radius > 0) {
|
|
3194
5198
|
this.theta = Math.atan2(v[0], v[1]);
|
|
3195
5199
|
this.phi = Math.acos(clamp(v[2] / this.radius, -1, 1));
|