@woosh/meep-engine 2.131.43 → 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 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.45",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -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,QAuBhB"}
@@ -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,19 @@ 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
+ 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
- // construct rotation matrix for the normal
29
- v3_matrix4_rotate(destination, destination_offset, x, y, z, matrix);
30
+ // Re-normalize
31
+ const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
30
32
 
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);
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":"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);