@woosh/meep-engine 2.131.45 → 2.131.47

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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/src/core/collection/heap/BinaryHeap.d.ts +8 -3
  3. package/src/core/collection/heap/BinaryHeap.d.ts.map +1 -1
  4. package/src/core/collection/heap/BinaryHeap.js +17 -6
  5. package/src/core/collection/heap/Uint32Heap.d.ts +4 -3
  6. package/src/core/collection/heap/Uint32Heap.d.ts.map +1 -1
  7. package/src/core/collection/heap/Uint32Heap.js +6 -3
  8. package/src/core/geom/3d/frustum/clipping_volume_matrix4_project.d.ts +11 -0
  9. package/src/core/geom/3d/frustum/clipping_volume_matrix4_project.d.ts.map +1 -0
  10. package/src/core/geom/3d/frustum/clipping_volume_matrix4_project.js +45 -0
  11. package/src/core/geom/3d/frustum/frustum_matrix4_project.d.ts.map +1 -1
  12. package/src/core/geom/3d/frustum/frustum_matrix4_project.js +4 -29
  13. package/src/core/geom/3d/frustum/hexahedron_from_aabb.d.ts +19 -0
  14. package/src/core/geom/3d/frustum/hexahedron_from_aabb.d.ts.map +1 -0
  15. package/src/core/geom/3d/frustum/{frustum_from_aabb.js → hexahedron_from_aabb.js} +20 -15
  16. package/src/core/geom/3d/plane/plane3_matrix4_project.d.ts.map +1 -1
  17. package/src/core/geom/3d/plane/plane3_matrix4_project.js +13 -16
  18. package/src/core/geom/vec3/v3_matrix4_rotate.d.ts +6 -1
  19. package/src/core/geom/vec3/v3_matrix4_rotate.d.ts.map +1 -1
  20. package/src/core/geom/vec3/v3_matrix4_rotate.js +32 -14
  21. package/src/core/geom/vec3/v3_matrix4_rotate_normal.d.ts +16 -0
  22. package/src/core/geom/vec3/v3_matrix4_rotate_normal.d.ts.map +1 -0
  23. package/src/core/geom/vec3/v3_matrix4_rotate_normal.js +55 -0
  24. package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_overlap_clipping_volume.d.ts.map +1 -1
  25. package/src/engine/graphics/geometry/buffered/query/bvh32_geometry_overlap_clipping_volume.js +5 -1
  26. package/src/core/geom/3d/frustum/frustum_from_aabb.d.ts +0 -14
  27. package/src/core/geom/3d/frustum/frustum_from_aabb.d.ts.map +0 -1
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.45",
8
+ "version": "2.131.47",
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
@@ -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":"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
+ {"version":3,"file":"plane3_matrix4_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/plane/plane3_matrix4_project.js"],"names":[],"mappings":"AAQA;;;;;;;;;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,10 @@
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 } from "../../vec3/v3_matrix4_rotate.js";
4
+ import { v3_matrix4_rotate_normal } from "../../vec3/v3_matrix4_rotate_normal.js";
5
+ import { v3_multiply_scalar } from "../../vec3/v3_multiply_scalar.js";
4
6
 
7
+ const scratch_v3_0 = new Float32Array(3);
5
8
 
6
9
  /**
7
10
  *
@@ -19,19 +22,13 @@ export function plane3_matrix4_project(
19
22
  x, y, z, w,
20
23
  ) {
21
24
 
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];
25
+ // build reference point in the new pane
26
+ v3_multiply_scalar(scratch_v3_0, 0, x, y, z, -w);
27
+ v3_matrix4_multiply(scratch_v3_0, 0, scratch_v3_0, 0, matrix);
29
28
 
30
- // Re-normalize
31
- const len = Math.sqrt(nx * nx + ny * ny + nz * nz);
29
+ // rotate normal vector
30
+ v3_matrix4_rotate_normal(destination, destination_offset, x, y, z, matrix);
32
31
 
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;
32
+ // figure out the new planar offset using new orientation and a reference point
33
+ destination[destination_offset + 3] = -v3_dot_array_array(scratch_v3_0, 0, destination, destination_offset);
37
34
  }
@@ -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 +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"}