@quake2ts/shared 0.0.743 → 0.0.748
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/browser/index.global.js +1 -1
- package/dist/browser/index.global.js.map +1 -1
- package/dist/cjs/index.cjs +54 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +52 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/math/mat4.d.ts +3 -0
- package/dist/types/math/mat4.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/math/mat4.ts +42 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -706,6 +706,25 @@ function createMat4Identity() {
|
|
|
706
706
|
1
|
|
707
707
|
]);
|
|
708
708
|
}
|
|
709
|
+
function mat4Identity(out = new Float32Array(16)) {
|
|
710
|
+
out[0] = 1;
|
|
711
|
+
out[1] = 0;
|
|
712
|
+
out[2] = 0;
|
|
713
|
+
out[3] = 0;
|
|
714
|
+
out[4] = 0;
|
|
715
|
+
out[5] = 1;
|
|
716
|
+
out[6] = 0;
|
|
717
|
+
out[7] = 0;
|
|
718
|
+
out[8] = 0;
|
|
719
|
+
out[9] = 0;
|
|
720
|
+
out[10] = 1;
|
|
721
|
+
out[11] = 0;
|
|
722
|
+
out[12] = 0;
|
|
723
|
+
out[13] = 0;
|
|
724
|
+
out[14] = 0;
|
|
725
|
+
out[15] = 1;
|
|
726
|
+
return out;
|
|
727
|
+
}
|
|
709
728
|
function multiplyMat4(a, b) {
|
|
710
729
|
const out = new Float32Array(16);
|
|
711
730
|
for (let row = 0; row < 4; row += 1) {
|
|
@@ -741,6 +760,38 @@ function mat4FromBasis(origin, axis) {
|
|
|
741
760
|
out[14] = origin.z;
|
|
742
761
|
return out;
|
|
743
762
|
}
|
|
763
|
+
function mat4Translate(out, v) {
|
|
764
|
+
const x = v.x, y = v.y, z = v.z;
|
|
765
|
+
out[12] = out[0] * x + out[4] * y + out[8] * z + out[12];
|
|
766
|
+
out[13] = out[1] * x + out[5] * y + out[9] * z + out[13];
|
|
767
|
+
out[14] = out[2] * x + out[6] * y + out[10] * z + out[14];
|
|
768
|
+
out[15] = out[3] * x + out[7] * y + out[11] * z + out[15];
|
|
769
|
+
return out;
|
|
770
|
+
}
|
|
771
|
+
function mat4Perspective(out, fovy, aspect, near, far) {
|
|
772
|
+
const f = 1 / Math.tan(fovy / 2);
|
|
773
|
+
out[0] = f / aspect;
|
|
774
|
+
out[1] = 0;
|
|
775
|
+
out[2] = 0;
|
|
776
|
+
out[3] = 0;
|
|
777
|
+
out[4] = 0;
|
|
778
|
+
out[5] = f;
|
|
779
|
+
out[6] = 0;
|
|
780
|
+
out[7] = 0;
|
|
781
|
+
out[8] = 0;
|
|
782
|
+
out[9] = 0;
|
|
783
|
+
out[11] = -1;
|
|
784
|
+
out[15] = 0;
|
|
785
|
+
if (far != null && far !== Infinity) {
|
|
786
|
+
const nf = 1 / (near - far);
|
|
787
|
+
out[10] = (far + near) * nf;
|
|
788
|
+
out[14] = 2 * far * near * nf;
|
|
789
|
+
} else {
|
|
790
|
+
out[10] = -1;
|
|
791
|
+
out[14] = -2 * near;
|
|
792
|
+
}
|
|
793
|
+
return out;
|
|
794
|
+
}
|
|
744
795
|
|
|
745
796
|
// src/bsp/contents.ts
|
|
746
797
|
var CONTENTS_NONE = 0;
|
|
@@ -6148,6 +6199,9 @@ exports.lengthSquaredVec3 = lengthSquaredVec3;
|
|
|
6148
6199
|
exports.lengthVec3 = lengthVec3;
|
|
6149
6200
|
exports.lerpAngle = lerpAngle;
|
|
6150
6201
|
exports.mat4FromBasis = mat4FromBasis;
|
|
6202
|
+
exports.mat4Identity = mat4Identity;
|
|
6203
|
+
exports.mat4Perspective = mat4Perspective;
|
|
6204
|
+
exports.mat4Translate = mat4Translate;
|
|
6151
6205
|
exports.mouseDeltaToViewDelta = mouseDeltaToViewDelta;
|
|
6152
6206
|
exports.multiplyMat4 = multiplyMat4;
|
|
6153
6207
|
exports.multiplyVec3 = multiplyVec3;
|