@woosh/meep-engine 2.131.43 → 2.131.46

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 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.43",
8
+ "version": "2.131.46",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Perform affine transform on a given frustum
3
+ * @param {number[]|Float32Array|Float64Array} output
4
+ * @param {number} output_offset
5
+ * @param {number[]|Float32Array|Float64Array} input
6
+ * @param {number} input_offset
7
+ * @param {number} plane_count
8
+ * @param {number[]|Float32Array|Float64Array} matrix4
9
+ */
10
+ export function clipping_volume_matrix4_project(output: number[] | Float32Array | Float64Array, output_offset: number, input: number[] | Float32Array | Float64Array, input_offset: number, plane_count: number, matrix4: number[] | Float32Array | Float64Array): void;
11
+ //# sourceMappingURL=clipping_volume_matrix4_project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipping_volume_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/frustum/clipping_volume_matrix4_project.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,wDAPW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,gBAClC,MAAM,eACN,MAAM,WACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAkC5C"}
@@ -0,0 +1,45 @@
1
+ import { assert } from "../../../assert.js";
2
+ import { plane3_matrix4_project } from "../plane/plane3_matrix4_project.js";
3
+
4
+ /**
5
+ * Perform affine transform on a given frustum
6
+ * @param {number[]|Float32Array|Float64Array} output
7
+ * @param {number} output_offset
8
+ * @param {number[]|Float32Array|Float64Array} input
9
+ * @param {number} input_offset
10
+ * @param {number} plane_count
11
+ * @param {number[]|Float32Array|Float64Array} matrix4
12
+ */
13
+ export function clipping_volume_matrix4_project(
14
+ output, output_offset,
15
+ input, input_offset,
16
+ plane_count,
17
+ matrix4
18
+ ) {
19
+ assert.isArrayLike(output, 'output');
20
+ assert.isNonNegativeInteger(output_offset, "output_offset");
21
+
22
+ assert.isArrayLike(input, 'input');
23
+ assert.greaterThanOrEqual(input.length, input_offset + plane_count*4, 'input too small');
24
+ assert.isNonNegativeInteger(input_offset, "input_offset");
25
+
26
+ assert.isArrayLike(matrix4, 'matrix4');
27
+
28
+ for (let plane_index = 0; plane_index < plane_count; plane_index++) {
29
+ const frustum_offset = plane_index * 4;
30
+
31
+ const i = input_offset + frustum_offset;
32
+ const o = output_offset + frustum_offset;
33
+
34
+ plane3_matrix4_project(
35
+ output, o,
36
+ matrix4,
37
+ input[i],
38
+ input[i + 1],
39
+ input[i + 2],
40
+ input[i + 3],
41
+ );
42
+
43
+ }
44
+
45
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"frustum_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/frustum/frustum_matrix4_project.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,gDANW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,gBAClC,MAAM,WACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAiC5C"}
1
+ {"version":3,"file":"frustum_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/frustum/frustum_matrix4_project.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,gDANW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,MAAM,SACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,gBAClC,MAAM,WACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAQ5C"}
@@ -1,5 +1,5 @@
1
- import { assert } from "../../../assert.js";
2
- import { plane3_matrix4_project } from "../plane/plane3_matrix4_project.js";
1
+ import { clipping_volume_matrix4_project } from "./clipping_volume_matrix4_project.js";
2
+
3
3
 
4
4
  /**
5
5
  * Perform affine transform on a given frustum
@@ -13,31 +13,6 @@ export function frustum_matrix4_project(
13
13
  output, output_offset,
14
14
  input, input_offset,
15
15
  matrix4
16
- ) {
17
- assert.isArrayLike(output, 'output');
18
- assert.isNonNegativeInteger(output_offset, "output_offset");
19
-
20
- assert.isArrayLike(input, 'input');
21
- assert.greaterThanOrEqual(input.length, input_offset + 24, 'input too small');
22
- assert.isNonNegativeInteger(input_offset, "input_offset");
23
-
24
- assert.isArrayLike(matrix4, 'matrix4');
25
-
26
- for (let plane_index = 0; plane_index < 6; plane_index++) {
27
- const frustum_offset = plane_index * 4;
28
-
29
- const i = input_offset + frustum_offset;
30
- const o = output_offset + frustum_offset;
31
-
32
- plane3_matrix4_project(
33
- output, o,
34
- matrix4,
35
- input[i],
36
- input[i + 1],
37
- input[i + 2],
38
- input[i + 3],
39
- );
40
-
41
- }
42
-
16
+ ){
17
+ clipping_volume_matrix4_project(output, output_offset, input, input_offset, 6, matrix4);
43
18
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Constructs an orthographic hexahedron from an Axis-Aligned Bounding Box.
3
+ * The planes are stored as 4-tuples (nx, ny, nz, d).
4
+ *
5
+ * Normals are facing inwards, i.e., the volume of positive.
6
+ *
7
+ * This can also be used for an orthographic camera frustum.
8
+ *
9
+ * @param {Float32Array|number[]} output
10
+ * @param {number} output_offset
11
+ * @param {number} x0 - Minimum X
12
+ * @param {number} y0 - Minimum Y
13
+ * @param {number} z0 - Minimum Z
14
+ * @param {number} x1 - Maximum X
15
+ * @param {number} y1 - Maximum Y
16
+ * @param {number} z1 - Maximum Z
17
+ */
18
+ export function hexahedron_from_aabb(output: Float32Array | number[], output_offset: number, x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void;
19
+ //# sourceMappingURL=hexahedron_from_aabb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hexahedron_from_aabb.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/frustum/hexahedron_from_aabb.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,6CATW,YAAY,GAAC,MAAM,EAAE,iBACrB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QA4ChB"}
@@ -1,6 +1,11 @@
1
1
  /**
2
- * Constructs an orthographic frustum from an Axis-Aligned Bounding Box.
2
+ * Constructs an orthographic hexahedron from an Axis-Aligned Bounding Box.
3
3
  * The planes are stored as 4-tuples (nx, ny, nz, d).
4
+ *
5
+ * Normals are facing inwards, i.e., the volume of positive.
6
+ *
7
+ * This can also be used for an orthographic camera frustum.
8
+ *
4
9
  * @param {Float32Array|number[]} output
5
10
  * @param {number} output_offset
6
11
  * @param {number} x0 - Minimum X
@@ -10,36 +15,36 @@
10
15
  * @param {number} y1 - Maximum Y
11
16
  * @param {number} z1 - Maximum Z
12
17
  */
13
- export function frustum_from_aabb(
18
+ export function hexahedron_from_aabb(
14
19
  output,
15
20
  output_offset,
16
21
  x0, y0, z0,
17
22
  x1, y1, z1
18
23
  ){
19
-
20
- // Left plane (x = x0): Normal points +X
21
- output[output_offset + 0] = 1;
24
+
25
+ // Right plane (x = x1): Normal points -X
26
+ output[output_offset + 0] = -1;
22
27
  output[output_offset + 1] = 0;
23
28
  output[output_offset + 2] = 0;
24
- output[output_offset + 3] = -x0;
29
+ output[output_offset + 3] = x1;
25
30
 
26
- // Right plane (x = x1): Normal points -X
27
- output[output_offset + 4] = -1;
31
+ // Left plane (x = x0): Normal points +X
32
+ output[output_offset + 4] = 1;
28
33
  output[output_offset + 5] = 0;
29
34
  output[output_offset + 6] = 0;
30
- output[output_offset + 7] = x1;
35
+ output[output_offset + 7] = -x0;
31
36
 
32
- // Bottom plane (y = y0): Normal points +Y
37
+ // Top plane (y = y1): Normal points -Y
33
38
  output[output_offset + 8] = 0;
34
- output[output_offset + 9] = 1;
39
+ output[output_offset + 9] = -1;
35
40
  output[output_offset + 10] = 0;
36
- output[output_offset + 11] = -y0;
41
+ output[output_offset + 11] = y1;
37
42
 
38
- // Top plane (y = y1): Normal points -Y
43
+ // Bottom plane (y = y0): Normal points +Y
39
44
  output[output_offset + 12] = 0;
40
- output[output_offset + 13] = -1;
45
+ output[output_offset + 13] = 1;
41
46
  output[output_offset + 14] = 0;
42
- output[output_offset + 15] = y1;
47
+ output[output_offset + 15] = -y0;
43
48
 
44
49
  // Near plane (z = z0): Normal points +Z
45
50
  output[output_offset + 16] = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"plane3_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/plane/plane3_matrix4_project.js"],"names":[],"mappings":"AAOA;;;;;;;;;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,QAiBhB"}
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,QAyBhB"}
@@ -1,9 +1,7 @@
1
- import { v3_dot_array_array } from "../../vec3/v3_dot_array_array.js";
2
- import { v3_matrix4_multiply } from "../../vec3/v3_matrix4_multiply.js";
3
- import { v3_matrix4_rotate } from "../../vec3/v3_matrix4_rotate.js";
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,21 @@ export function plane3_matrix4_project(
21
19
  x, y, z, w,
22
20
  ) {
23
21
 
24
- // build reference point in the new pane
25
- v3_multiply_scalar(scratch_v3_0, 0, x, y, z, -w);
26
- v3_matrix4_multiply(scratch_v3_0, 0, scratch_v3_0, 0, matrix);
22
+ // the formula is = vec4*T(-mat4)
23
+
24
+ m4_invert(mat_inv, matrix);
25
+
26
+ // multiply by transpose
27
+ const nx = x * mat_inv[0] + y * mat_inv[1] + z * mat_inv[2] + w * mat_inv[3];
28
+ const ny = x * mat_inv[4] + y * mat_inv[5] + z * mat_inv[6] + w * mat_inv[7];
29
+ const nz = x * mat_inv[8] + y * mat_inv[9] + z * mat_inv[10] + w * mat_inv[11];
30
+ const nw = x * mat_inv[12] + y * mat_inv[13] + z * mat_inv[14] + w * mat_inv[15];
27
31
 
28
- // construct rotation matrix for the normal
29
- v3_matrix4_rotate(destination, destination_offset, x, y, z, matrix);
32
+ // Re-normalize
33
+ const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
30
34
 
31
- // figure out new planar offset using new orientation and a reference point
32
- destination[destination_offset + 3] = -v3_dot_array_array(scratch_v3_0, 0, destination, destination_offset);
35
+ destination[destination_offset] = nx / len;
36
+ destination[destination_offset + 1] = ny / len;
37
+ destination[destination_offset + 2] = nz / len;
38
+ destination[destination_offset + 3] = nw / len;
33
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"v3_matrix4_rotate.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_matrix4_rotate.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,0CAPW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,EAAE,GAAC,YAAY,QAkB/B"}
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
- const _x = m4[0] * x + m4[4] * y + m4[8] * z;
19
- const _y = m4[1] * x + m4[5] * y + m4[9] * z;
20
- const _z = m4[2] * x + m4[6] * y + m4[10] * z;
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);
@@ -1 +1 @@
1
- {"version":3,"file":"bvh32_geometry_overlap_clipping_volume.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/buffered/query/bvh32_geometry_overlap_clipping_volume.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,uFAVW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,iBAC1B,MAAM,iBACN,MAAM,0BACN,OAAO,WACP,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,SAAS,UACpC,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,eACN,MAAM,GACJ,OAAO,CAmFnB"}
1
+ {"version":3,"file":"bvh32_geometry_overlap_clipping_volume.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/buffered/query/bvh32_geometry_overlap_clipping_volume.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,uFAVW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,iBAC1B,MAAM,iBACN,MAAM,0BACN,OAAO,WACP,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,SAAS,UACpC,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,eACN,MAAM,GACJ,OAAO,CAuFnB"}
@@ -32,6 +32,10 @@ export function bvh32_geometry_overlap_clipping_volume(
32
32
  planes, planes_offset, plane_count
33
33
  ) {
34
34
 
35
+ assert.isBoolean(vertex_data_normalized, 'vertex_data_normalized');
36
+ assert.isNonNegativeInteger(planes_offset, 'planes_offset');
37
+ assert.isNonNegativeInteger(plane_count, 'plane_count');
38
+
35
39
  const hit_count = bvh32_query_user_data_overlaps_clipping_volume(
36
40
  scratch_array, 0,
37
41
  bvh,
@@ -79,7 +83,7 @@ export function bvh32_geometry_overlap_clipping_volume(
79
83
  let cz = vertices[c_address + 2];
80
84
 
81
85
  // denormalize if necessary
82
- if(vertex_data_normalized) {
86
+ if (vertex_data_normalized) {
83
87
  ax = typed_array_value_denormalize(ax, vertices);
84
88
  ay = typed_array_value_denormalize(ay, vertices);
85
89
  az = typed_array_value_denormalize(az, vertices);
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}