@woosh/meep-engine 2.131.46 → 2.131.48

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.46",
8
+ "version": "2.131.48",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,16 +1,21 @@
1
1
  export default BinaryHeap;
2
2
  /**
3
3
  * Min-Heap implementation with a score function.
4
- * The data structure is a binary heap where elements are removed in order defined by scoring function
4
+ * Elements are removed in ascending order by their score, meaning that the item with the lowest score is removed first.
5
+ * The data structure is a binary heap where elements are removed in order defined by scoring function.
6
+ *
7
+ * The most common use case for this structure is for a priority queue.
8
+ *
5
9
  * @template T
10
+ * @see Uint32Heap
6
11
  */
7
12
  declare class BinaryHeap<T> {
8
13
  /**
9
14
  * @template T
10
- * @param {function(el:T):number} scoreFunction
15
+ * @param {function(el:T):number} min_score_function
11
16
  * @constructor
12
17
  */
13
- constructor(scoreFunction: any);
18
+ constructor(min_score_function: any);
14
19
  /**
15
20
  * @private
16
21
  * @type {T[]}
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryHeap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/BinaryHeap.js"],"names":[],"mappings":";AAEA;;;;GAIG;AACH;IAaI;;;;OAIG;IACH,gCAQC;IAzBD;;;OAGG;IACH,aAAU;IAEV;;;OAGG;IACH,eAAW;IASP;;;OAGG;IACH,8BAFuB,MAAM,CAEK;IAItC;;;OAGG;IACH,iBA8BC;IAED;;;OAGG;IACH,mBAmEC;IAED;;;OAGG;IACH,OAFY,CAAC,CA0BZ;IAED;;;OAGG;IACH,QAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;;OAIG;IACH,aAHW,CAAC,GACC,OAAO,CAYnB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAOhB;IAED;;OAEG;IACH,cAGC;IAED;;;;OAIG;IACH,eAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAWnB;IAED;;;OAGG;IACH,SAFW,CAAC,QAUX;IAGL;;;;OAIG;IACH,uBAFU,OAAO,CAEgB;CAPhC"}
1
+ {"version":3,"file":"BinaryHeap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/BinaryHeap.js"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AACH;IAaI;;;;OAIG;IACH,qCAUC;IA3BD;;;OAGG;IACH,aAAU;IAEV;;;OAGG;IACH,eAAW;IAWP;;;OAGG;IACH,8BAFuB,MAAM,CAEU;IAI3C;;;OAGG;IACH,iBAkCC;IAED;;;OAGG;IACH,mBAmEC;IAED;;;OAGG;IACH,OAFY,CAAC,CA0BZ;IAED;;;OAGG;IACH,QAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;;OAIG;IACH,aAHW,CAAC,GACC,OAAO,CAYnB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAOhB;IAED;;OAEG;IACH,cAGC;IAED;;;;OAIG;IACH,eAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAWnB;IAED;;;OAGG;IACH,SAFW,CAAC,QAUX;IAGL;;;;OAIG;IACH,uBAFU,OAAO,CAEgB;CAPhC"}
@@ -2,8 +2,13 @@ import { assert } from "../../assert.js";
2
2
 
3
3
  /**
4
4
  * Min-Heap implementation with a score function.
5
- * The data structure is a binary heap where elements are removed in order defined by scoring function
5
+ * Elements are removed in ascending order by their score, meaning that the item with the lowest score is removed first.
6
+ * The data structure is a binary heap where elements are removed in order defined by scoring function.
7
+ *
8
+ * The most common use case for this structure is for a priority queue.
9
+ *
6
10
  * @template T
11
+ * @see Uint32Heap
7
12
  */
8
13
  class BinaryHeap {
9
14
  /**
@@ -20,16 +25,18 @@ class BinaryHeap {
20
25
 
21
26
  /**
22
27
  * @template T
23
- * @param {function(el:T):number} scoreFunction
28
+ * @param {function(el:T):number} min_score_function
24
29
  * @constructor
25
30
  */
26
- constructor(scoreFunction) {
31
+ constructor(min_score_function) {
32
+
33
+ assert.isFunction(min_score_function, "scoreFunction");
27
34
 
28
35
  /**
29
36
  *
30
37
  * @type {function(T): number}
31
38
  */
32
- this.scoreFunction = scoreFunction;
39
+ this.scoreFunction = min_score_function;
33
40
 
34
41
  }
35
42
 
@@ -46,8 +53,10 @@ class BinaryHeap {
46
53
 
47
54
  let index = pos;
48
55
 
49
- let value = data[index];
50
- let score = this.scoreFunction(value);
56
+ const value = data[index];
57
+ const score = this.scoreFunction(value);
58
+
59
+ assert.isNumber(score, "score");
51
60
 
52
61
  while (index > 0) {
53
62
 
@@ -56,6 +65,8 @@ class BinaryHeap {
56
65
  const parentValue = data[parentIndex];
57
66
  const parentScore = this.scoreFunction(parentValue);
58
67
 
68
+ assert.isNumber(parentScore, "parentScore");
69
+
59
70
  if (score < parentScore) {
60
71
  //swap
61
72
 
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Binary Heap implementation that stores uin32 ID along with a floating point score value
3
- * Very fast and compact
4
- * Inspired by Blender's heap implementation found here: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/BLI_heap.c
2
+ * Binary Heap implementation that stores uin32 ID along with a floating point score value.
3
+ * Very fast and compact.
4
+ *
5
+ * @see BinaryHeap
5
6
  */
6
7
  export class Uint32Heap {
7
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Uint32Heap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/Uint32Heap.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH;IACI;;;OAGG;IACH,+BAFW,MAAM,EAkChB;IA7BG,2BAA0E;IAE1E;;;;OAIG;IACH,sBAAwD;IAExD;;;;OAIG;IACH,uBAA0D;IAE1D;;;;OAIG;IACH,mBAAkC;IAElC;;;;OAIG;IACH,eAAe;IAGnB;;;OAGG;IACH,wBAsBC;IAED;;;;;OAKG;IACH,gBAOC;IAED;;;;;OAKG;IACH,aAiBC;IAED;;;OAGG;IACH,kBA6BC;IAED;;;;OAIG;IACH,gBAeC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,YAFa,OAAO,CAInB;IAED,mBAEC;IAED,kBAoBC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,cAEC;IAED;;;;OAIG;IACH,WAHW,MAAM,GACJ,OAAO,CAWnB;IAED;;;OAGG;IACH,yBAFW,MAAM,QAehB;IAED;;;;OAIG;IACH,iBAHW,MAAM,SACN,MAAM,QAUhB;IAED;;;;OAIG;IACH,+BAHW,MAAM,SACN,MAAM,QAiBhB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,MAAM,CAYlB;IAGD;;;;OAIG;IACH,qBAHW,MAAM,SACN,MAAM,QAUhB;IAED;;;;OAIG;IACH,WAHW,MAAM,SACN,MAAM,QA0BhB;CAGJ"}
1
+ {"version":3,"file":"Uint32Heap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/Uint32Heap.js"],"names":[],"mappings":"AAiDA;;;;;GAKG;AACH;IAGI;;;OAGG;IACH,+BAFW,MAAM,EAkChB;IA7BG,2BAA0E;IAE1E;;;;OAIG;IACH,sBAAwD;IAExD;;;;OAIG;IACH,uBAA0D;IAE1D;;;;OAIG;IACH,mBAAkC;IAElC;;;;OAIG;IACH,eAAe;IAGnB;;;OAGG;IACH,wBAsBC;IAED;;;;;OAKG;IACH,gBAOC;IAED;;;;;OAKG;IACH,aAiBC;IAED;;;OAGG;IACH,kBA6BC;IAED;;;;OAIG;IACH,gBAeC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,YAFa,OAAO,CAInB;IAED,mBAEC;IAED,kBAoBC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,cAEC;IAED;;;;OAIG;IACH,WAHW,MAAM,GACJ,OAAO,CAWnB;IAED;;;OAGG;IACH,yBAFW,MAAM,QAehB;IAED;;;;OAIG;IACH,iBAHW,MAAM,SACN,MAAM,QAUhB;IAED;;;;OAIG;IACH,+BAHW,MAAM,SACN,MAAM,QAiBhB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,MAAM,CAYlB;IAGD;;;;OAIG;IACH,qBAHW,MAAM,SACN,MAAM,QAUhB;IAED;;;;OAIG;IACH,WAHW,MAAM,SACN,MAAM,QA0BhB;CAGJ"}
@@ -48,11 +48,14 @@ function HEAP_RIGHT(i) {
48
48
  }
49
49
 
50
50
  /**
51
- * Binary Heap implementation that stores uin32 ID along with a floating point score value
52
- * Very fast and compact
53
- * Inspired by Blender's heap implementation found here: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/BLI_heap.c
51
+ * Binary Heap implementation that stores uin32 ID along with a floating point score value.
52
+ * Very fast and compact.
53
+ *
54
+ * @see BinaryHeap
54
55
  */
55
56
  export class Uint32Heap {
57
+ // Inspired by Blender's heap implementation found here: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/BLI_heap.c
58
+
56
59
  /**
57
60
  *
58
61
  * @param {number} [initial_capacity] Can supply initial capacity, heap will still grow when necessary. This allows to prevent needless re-allocations when max heap size is known in advance
@@ -1 +1 @@
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
+ {"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,7 +1,9 @@
1
- import { m4_invert } from "../mat4/m4_invert.js";
2
-
3
- const mat_inv = new Float32Array(16);
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_normal } from "../../vec3/v3_matrix4_rotate_normal.js";
4
+ import { v3_multiply_scalar } from "../../vec3/v3_multiply_scalar.js";
4
5
 
6
+ const scratch_v3_0 = new Float32Array(3);
5
7
 
6
8
  /**
7
9
  *
@@ -19,21 +21,13 @@ export function plane3_matrix4_project(
19
21
  x, y, z, w,
20
22
  ) {
21
23
 
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];
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);
31
27
 
32
- // Re-normalize
33
- const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
28
+ // rotate normal vector
29
+ v3_matrix4_rotate_normal(destination, destination_offset, x, y, z, matrix);
34
30
 
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;
31
+ // figure out the 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);
39
33
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Produces a numeric result to indicate which side of the plane the triangle is on
3
+ * between +3 and -3:
4
+ * +3 means that all vertices ave above the plane
5
+ * -3 means all vertices are below the plane
6
+ * values in between indicate that the plane cuts through the triangle
7
+ *
8
+ * @param {number} plane_normal_x
9
+ * @param {number} plane_normal_y
10
+ * @param {number} plane_normal_z
11
+ * @param {number} plane_constant
12
+ * @param {number} ax
13
+ * @param {number} ay
14
+ * @param {number} az
15
+ * @param {number} bx
16
+ * @param {number} by
17
+ * @param {number} bz
18
+ * @param {number} cx
19
+ * @param {number} cy
20
+ * @param {number} cz
21
+ * @returns {number}
22
+ */
23
+ export function triangle_compute_plane_side(plane_normal_x: number, plane_normal_y: number, plane_normal_z: number, plane_constant: number, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): number;
24
+ //# sourceMappingURL=triangle_compute_plane_side.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triangle_compute_plane_side.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/triangle_compute_plane_side.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,4DAfW,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAgBlB"}
@@ -2,7 +2,11 @@ import { v3_dot } from "../../vec3/v3_dot.js";
2
2
 
3
3
  /**
4
4
  * Produces a numeric result to indicate which side of the plane the triangle is on
5
- * between +3 and -3, +3 means that all vertices ave above the plane, -3 means all vertices are below the plane, values in between indicate that plane cuts throught the triangle
5
+ * between +3 and -3:
6
+ * +3 means that all vertices ave above the plane
7
+ * -3 means all vertices are below the plane
8
+ * values in between indicate that the plane cuts through the triangle
9
+ *
6
10
  * @param {number} plane_normal_x
7
11
  * @param {number} plane_normal_y
8
12
  * @param {number} plane_normal_z
@@ -18,7 +22,7 @@ import { v3_dot } from "../../vec3/v3_dot.js";
18
22
  * @param {number} cz
19
23
  * @returns {number}
20
24
  */
21
- export function computeTrianglePlaneSide(
25
+ export function triangle_compute_plane_side(
22
26
  plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
23
27
  ax, ay, az,
24
28
  bx, by, bz,
@@ -27,9 +31,9 @@ export function computeTrianglePlaneSide(
27
31
  let result = 0;
28
32
 
29
33
  // compute side for each point
30
- result += v3_dot(plane_normal_x, plane_normal_y, plane_normal_z, ax, ay, az) >= plane_constant ? 1 : -1;
31
- result += v3_dot(plane_normal_x, plane_normal_y, plane_normal_z, bx, by, bz) >= plane_constant ? 1 : -1;
32
- result += v3_dot(plane_normal_x, plane_normal_y, plane_normal_z, cx, cy, cz) >= plane_constant ? 1 : -1;
34
+ result += ( v3_dot(plane_normal_x, plane_normal_y, plane_normal_z, ax, ay, az) + plane_constant ) >= 0 ? 1 : -1;
35
+ result += ( v3_dot(plane_normal_x, plane_normal_y, plane_normal_z, bx, by, bz) + plane_constant ) >= 0 ? 1 : -1;
36
+ result += ( v3_dot(plane_normal_x, plane_normal_y, plane_normal_z, cx, cy, cz) + plane_constant ) >= 0 ? 1 : -1;
33
37
 
34
38
  return result;
35
39
  }
@@ -1,4 +1,4 @@
1
- import { computeTrianglePlaneSide } from "./computeTrianglePlaneSide.js";
1
+ import { triangle_compute_plane_side } from "./triangle_compute_plane_side.js";
2
2
 
3
3
  /**
4
4
  * @param {number[]|Float32Array} planes
@@ -31,7 +31,7 @@ export function triangle_intersects_clipping_volume(
31
31
  const plane_normal_z = planes[plane_address + 2];
32
32
  const plane_constant = planes[plane_address + 3];
33
33
 
34
- const side = computeTrianglePlaneSide(
34
+ const side = triangle_compute_plane_side(
35
35
  plane_normal_x,
36
36
  plane_normal_y,
37
37
  plane_normal_z,
@@ -1,5 +1,10 @@
1
1
  /**
2
- * Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
2
+ *
3
+ * Perform rotation on a direction vector using a 4x4 affine transform matrix.
4
+ * Input is expected to be normalized.
5
+ * Correctly handles non-uniform scaling.
6
+ * Output is normalized.
7
+ *
3
8
  * @param {number[]|Float32Array} output
4
9
  * @param {number} output_offset
5
10
  * @param {number} x
@@ -1 +1 @@
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
+ {"version":3,"file":"v3_matrix4_rotate.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_matrix4_rotate.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,0CAPW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,EAAE,GAAC,YAAY,QAkC/B"}
@@ -1,10 +1,12 @@
1
- import { m4_invert } from "../3d/mat4/m4_invert.js";
2
1
  import { v3_length } from "./v3_length.js";
3
2
 
4
- const m4_inv = new Float32Array(16);
5
-
6
3
  /**
7
- * Perform rotation on a direction vector using 3x3 portion of a 4x4 matrix
4
+ *
5
+ * Perform rotation on a direction vector using a 4x4 affine transform matrix.
6
+ * Input is expected to be normalized.
7
+ * Correctly handles non-uniform scaling.
8
+ * Output is normalized.
9
+ *
8
10
  * @param {number[]|Float32Array} output
9
11
  * @param {number} output_offset
10
12
  * @param {number} x
@@ -18,16 +20,32 @@ export function v3_matrix4_rotate(
18
20
  m4
19
21
  ) {
20
22
 
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;
23
+ const _x = m4[0] * x + m4[4] * y + m4[8] * z;
24
+ const _y = m4[1] * x + m4[5] * y + m4[9] * z;
25
+ const _z = m4[2] * x + m4[6] * y + m4[10] * z;
26
26
 
27
27
  // perform normalization
28
- const norm = 1 / v3_length(_x, _y, _z);
28
+ const length = v3_length(_x, _y, _z);
29
+
30
+ if (length > 1e-7) {
31
+
32
+ // re-normalize
33
+ const norm = 1 / length;
34
+
35
+ output[output_offset] = _x * norm;
36
+ output[output_offset + 1] = _y * norm;
37
+ output[output_offset + 2] = _z * norm;
38
+
39
+ } else {
40
+
41
+ // The transform is invalid.
42
+ // Provide arbitrary vector.
43
+
44
+ output[output_offset] = 0;
45
+ output[output_offset + 1] = 0;
46
+ output[output_offset + 2] = 0;
47
+
48
+ }
49
+ }
50
+
29
51
 
30
- output[output_offset] = _x * norm;
31
- output[output_offset + 1] = _y * norm;
32
- output[output_offset + 2] = _z * norm;
33
- }
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ * Perform rotation on a normal vector using a 4x4 affine transform matrix.
4
+ * Input is expected to be normalized.
5
+ * Correctly handles non-uniform scaling.
6
+ * Output is normalized.
7
+ *
8
+ * @param {number[]|Float32Array} output
9
+ * @param {number} output_offset
10
+ * @param {number} x
11
+ * @param {number} y
12
+ * @param {number} z
13
+ * @param {number[]|Float32Array} m4
14
+ */
15
+ export function v3_matrix4_rotate_normal(output: number[] | Float32Array, output_offset: number, x: number, y: number, z: number, m4: number[] | Float32Array): void;
16
+ //# sourceMappingURL=v3_matrix4_rotate_normal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_matrix4_rotate_normal.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_matrix4_rotate_normal.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,iDAPW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,MACN,MAAM,EAAE,GAAC,YAAY,QAqC/B"}
@@ -0,0 +1,55 @@
1
+ import { m4_invert } from "../3d/mat4/m4_invert.js";
2
+ import { v3_length } from "./v3_length.js";
3
+
4
+ const m4_inv = new Float32Array(16);
5
+
6
+ /**
7
+ *
8
+ * Perform rotation on a normal vector using a 4x4 affine transform matrix.
9
+ * Input is expected to be normalized.
10
+ * Correctly handles non-uniform scaling.
11
+ * Output is normalized.
12
+ *
13
+ * @param {number[]|Float32Array} output
14
+ * @param {number} output_offset
15
+ * @param {number} x
16
+ * @param {number} y
17
+ * @param {number} z
18
+ * @param {number[]|Float32Array} m4
19
+ */
20
+ export function v3_matrix4_rotate_normal(
21
+ output, output_offset,
22
+ x, y, z,
23
+ m4
24
+ ) {
25
+
26
+ m4_invert(m4_inv, m4);
27
+
28
+ // this is transposed multiplication: T(M) * vec3
29
+ const _x = m4_inv[0] * x + m4_inv[1] * y + m4_inv[2] * z;
30
+ const _y = m4_inv[4] * x + m4_inv[5] * y + m4_inv[6] * z;
31
+ const _z = m4_inv[8] * x + m4_inv[9] * y + m4_inv[10] * z;
32
+
33
+ // perform normalization
34
+ const length = v3_length(_x, _y, _z);
35
+
36
+ if (length > 1e-7) {
37
+
38
+ // re-normalize
39
+ const norm = 1 / length;
40
+
41
+ output[output_offset] = _x * norm;
42
+ output[output_offset + 1] = _y * norm;
43
+ output[output_offset + 2] = _z * norm;
44
+
45
+ } else {
46
+
47
+ // The transform is invalid.
48
+ // Provide arbitrary vector.
49
+
50
+ output[output_offset] = 0;
51
+ output[output_offset + 1] = 0;
52
+ output[output_offset + 2] = 0;
53
+
54
+ }
55
+ }
@@ -1,20 +0,0 @@
1
- /**
2
- * Produces a numeric result to indicate which side of the plane the triangle is on
3
- * between +3 and -3, +3 means that all vertices ave above the plane, -3 means all vertices are below the plane, values in between indicate that plane cuts throught the triangle
4
- * @param {number} plane_normal_x
5
- * @param {number} plane_normal_y
6
- * @param {number} plane_normal_z
7
- * @param {number} plane_constant
8
- * @param {number} ax
9
- * @param {number} ay
10
- * @param {number} az
11
- * @param {number} bx
12
- * @param {number} by
13
- * @param {number} bz
14
- * @param {number} cx
15
- * @param {number} cy
16
- * @param {number} cz
17
- * @returns {number}
18
- */
19
- export function computeTrianglePlaneSide(plane_normal_x: number, plane_normal_y: number, plane_normal_z: number, plane_constant: number, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): number;
20
- //# sourceMappingURL=computeTrianglePlaneSide.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"computeTrianglePlaneSide.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTrianglePlaneSide.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,yDAfW,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAgBlB"}