@woosh/meep-engine 2.131.42 → 2.131.45
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/package.json +1 -1
- package/src/core/geom/3d/frustum/frustum_from_aabb.d.ts +14 -0
- package/src/core/geom/3d/frustum/frustum_from_aabb.d.ts.map +1 -0
- package/src/core/geom/3d/frustum/frustum_from_aabb.js +55 -0
- package/src/core/geom/3d/plane/plane3_matrix4_project.d.ts.map +1 -1
- package/src/core/geom/3d/plane/plane3_matrix4_project.js +16 -12
- package/src/core/geom/vec3/v3_matrix4_rotate.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_matrix4_rotate.js +8 -3
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.131.
|
|
8
|
+
"version": "2.131.45",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs an orthographic frustum from an Axis-Aligned Bounding Box.
|
|
3
|
+
* The planes are stored as 4-tuples (nx, ny, nz, d).
|
|
4
|
+
* @param {Float32Array|number[]} output
|
|
5
|
+
* @param {number} output_offset
|
|
6
|
+
* @param {number} x0 - Minimum X
|
|
7
|
+
* @param {number} y0 - Minimum Y
|
|
8
|
+
* @param {number} z0 - Minimum Z
|
|
9
|
+
* @param {number} x1 - Maximum X
|
|
10
|
+
* @param {number} y1 - Maximum Y
|
|
11
|
+
* @param {number} z1 - Maximum Z
|
|
12
|
+
*/
|
|
13
|
+
export function frustum_from_aabb(output: Float32Array | number[], output_offset: number, x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void;
|
|
14
|
+
//# sourceMappingURL=frustum_from_aabb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frustum_from_aabb.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/frustum/frustum_from_aabb.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,0CATW,YAAY,GAAC,MAAM,EAAE,iBACrB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QA4ChB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs an orthographic frustum from an Axis-Aligned Bounding Box.
|
|
3
|
+
* The planes are stored as 4-tuples (nx, ny, nz, d).
|
|
4
|
+
* @param {Float32Array|number[]} output
|
|
5
|
+
* @param {number} output_offset
|
|
6
|
+
* @param {number} x0 - Minimum X
|
|
7
|
+
* @param {number} y0 - Minimum Y
|
|
8
|
+
* @param {number} z0 - Minimum Z
|
|
9
|
+
* @param {number} x1 - Maximum X
|
|
10
|
+
* @param {number} y1 - Maximum Y
|
|
11
|
+
* @param {number} z1 - Maximum Z
|
|
12
|
+
*/
|
|
13
|
+
export function frustum_from_aabb(
|
|
14
|
+
output,
|
|
15
|
+
output_offset,
|
|
16
|
+
x0, y0, z0,
|
|
17
|
+
x1, y1, z1
|
|
18
|
+
){
|
|
19
|
+
|
|
20
|
+
// Left plane (x = x0): Normal points +X
|
|
21
|
+
output[output_offset + 0] = 1;
|
|
22
|
+
output[output_offset + 1] = 0;
|
|
23
|
+
output[output_offset + 2] = 0;
|
|
24
|
+
output[output_offset + 3] = -x0;
|
|
25
|
+
|
|
26
|
+
// Right plane (x = x1): Normal points -X
|
|
27
|
+
output[output_offset + 4] = -1;
|
|
28
|
+
output[output_offset + 5] = 0;
|
|
29
|
+
output[output_offset + 6] = 0;
|
|
30
|
+
output[output_offset + 7] = x1;
|
|
31
|
+
|
|
32
|
+
// Bottom plane (y = y0): Normal points +Y
|
|
33
|
+
output[output_offset + 8] = 0;
|
|
34
|
+
output[output_offset + 9] = 1;
|
|
35
|
+
output[output_offset + 10] = 0;
|
|
36
|
+
output[output_offset + 11] = -y0;
|
|
37
|
+
|
|
38
|
+
// Top plane (y = y1): Normal points -Y
|
|
39
|
+
output[output_offset + 12] = 0;
|
|
40
|
+
output[output_offset + 13] = -1;
|
|
41
|
+
output[output_offset + 14] = 0;
|
|
42
|
+
output[output_offset + 15] = y1;
|
|
43
|
+
|
|
44
|
+
// Near plane (z = z0): Normal points +Z
|
|
45
|
+
output[output_offset + 16] = 0;
|
|
46
|
+
output[output_offset + 17] = 0;
|
|
47
|
+
output[output_offset + 18] = 1;
|
|
48
|
+
output[output_offset + 19] = -z0;
|
|
49
|
+
|
|
50
|
+
// Far plane (z = z1): Normal points -Z
|
|
51
|
+
output[output_offset + 20] = 0;
|
|
52
|
+
output[output_offset + 21] = 0;
|
|
53
|
+
output[output_offset + 22] = -1;
|
|
54
|
+
output[output_offset + 23] = z1;
|
|
55
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plane3_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/plane/plane3_matrix4_project.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plane3_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/plane/plane3_matrix4_project.js"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,oDARW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,sBAClC,MAAM,UACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,KAClC,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAuBhB"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { v3_multiply_scalar } from "../../vec3/v3_multiply_scalar.js";
|
|
1
|
+
import { m4_invert } from "../mat4/m4_invert.js";
|
|
2
|
+
|
|
3
|
+
const mat_inv = new Float32Array(16);
|
|
5
4
|
|
|
6
|
-
const scratch_v3_0 = new Float32Array(3);
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
*
|
|
@@ -21,13 +19,19 @@ export function plane3_matrix4_project(
|
|
|
21
19
|
x, y, z, w,
|
|
22
20
|
) {
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
m4_invert(mat_inv, matrix);
|
|
23
|
+
|
|
24
|
+
// multiply by transpose
|
|
25
|
+
const nx = x * mat_inv[0] + y * mat_inv[1] + z * mat_inv[2] + w * mat_inv[3];
|
|
26
|
+
const ny = x * mat_inv[4] + y * mat_inv[5] + z * mat_inv[6] + w * mat_inv[7];
|
|
27
|
+
const nz = x * mat_inv[8] + y * mat_inv[9] + z * mat_inv[10] + w * mat_inv[11];
|
|
28
|
+
const nw = x * mat_inv[12] + y * mat_inv[13] + z * mat_inv[14] + w * mat_inv[15];
|
|
27
29
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
+
// Re-normalize
|
|
31
|
+
const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
destination[destination_offset +
|
|
33
|
+
destination[destination_offset] = nx / len;
|
|
34
|
+
destination[destination_offset + 1] = ny / len;
|
|
35
|
+
destination[destination_offset + 2] = nz / len;
|
|
36
|
+
destination[destination_offset + 3] = nw / len;
|
|
33
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v3_matrix4_rotate.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_matrix4_rotate.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v3_matrix4_rotate.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_matrix4_rotate.js"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,0CAPW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,EAAE,GAAC,YAAY,QAoB/B"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { m4_invert } from "../3d/mat4/m4_invert.js";
|
|
1
2
|
import { v3_length } from "./v3_length.js";
|
|
2
3
|
|
|
4
|
+
const m4_inv = new Float32Array(16);
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
|
|
5
8
|
* @param {number[]|Float32Array} output
|
|
@@ -15,9 +18,11 @@ export function v3_matrix4_rotate(
|
|
|
15
18
|
m4
|
|
16
19
|
) {
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
+
m4_invert(m4_inv, m4);
|
|
22
|
+
|
|
23
|
+
const _x = m4_inv[0] * x + m4_inv[1] * y + m4_inv[2] * z;
|
|
24
|
+
const _y = m4_inv[4] * x + m4_inv[5] * y + m4_inv[6] * z;
|
|
25
|
+
const _z = m4_inv[8] * x + m4_inv[9] * y + m4_inv[10] * z;
|
|
21
26
|
|
|
22
27
|
// perform normalization
|
|
23
28
|
const norm = 1 / v3_length(_x, _y, _z);
|