@woosh/meep-engine 2.126.52 → 2.126.54

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.126.52",
8
+ "version": "2.126.54",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,5 +1,4 @@
1
1
  /**
2
- *
3
2
  * @param {number[]} result
4
3
  * @param {number} result_offset
5
4
  * @param {number} plane_mask if bit is set to 0, that plane is not allowed to move
@@ -1 +1 @@
1
- {"version":3,"file":"compute_tight_near_far_clipping_planes.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,+DAPW,MAAM,EAAE,iBACR,MAAM,cACN,MAAM,OACN,GAAG,WACH,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,GACrC,OAAO,CAwMnB"}
1
+ {"version":3,"file":"compute_tight_near_far_clipping_planes.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,+DAPW,MAAM,EAAE,iBACR,MAAM,cACN,MAAM,OACN,GAAG,WACH,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,GACrC,OAAO,CA4MnB"}
@@ -1,3 +1,4 @@
1
+ import { assert } from "../../../assert.js";
1
2
  import { array_copy } from "../../../collection/array/array_copy.js";
2
3
  import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
3
4
  import { v3_distance_above_plane } from "../../../geom/vec3/v3_distance_above_plane.js";
@@ -10,7 +11,6 @@ const scratch_aabb = [];
10
11
  const scratch_frustum = new Float32Array(24);
11
12
 
12
13
  /**
13
- *
14
14
  * @param {number[]} result
15
15
  * @param {number} result_offset
16
16
  * @param {number} plane_mask if bit is set to 0, that plane is not allowed to move
@@ -25,6 +25,8 @@ export function compute_tight_near_far_clipping_planes(
25
25
  bvh,
26
26
  frustum
27
27
  ) {
28
+ assert.isNonNegativeInteger(result_offset, 'result_offset');
29
+ assert.isNonNegativeInteger(plane_mask, 'plane_mask');
28
30
 
29
31
  // initialize result
30
32
  array_copy(frustum, 0, scratch_frustum, 0, 24);
@@ -79,6 +81,8 @@ export function compute_tight_near_far_clipping_planes(
79
81
  const _y1 = scratch_aabb[4];
80
82
  const _z1 = scratch_aabb[5];
81
83
 
84
+ // bitset of relaxed planes affected by this node
85
+ // lets us discard intermediate nodes that would not affect any planes
82
86
  let collision_mask = 0;
83
87
 
84
88
  for (let plane_index = 0; plane_index < 6; plane_index++) {
@@ -126,11 +130,11 @@ export function compute_tight_near_far_clipping_planes(
126
130
  plane_normal_x, plane_normal_y, plane_normal_z, 0
127
131
  );
128
132
 
129
- if(distance_above_plane< plane_offset){
133
+ if (distance_above_plane < plane_offset) {
130
134
  collision_mask |= (1 << plane_index);
131
135
  }
132
136
 
133
- }else {
137
+ } else {
134
138
 
135
139
  // fixed plane
136
140
  const distance_above_plane = v3_distance_above_plane(
@@ -151,7 +155,7 @@ export function compute_tight_near_far_clipping_planes(
151
155
 
152
156
  if (!node_is_leaf) {
153
157
 
154
- if(collision_mask === 0){
158
+ if (collision_mask === 0) {
155
159
  // does not affect any planes, skip
156
160
  continue;
157
161
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Compute average-weighted centroid of a set of 3d vectors
3
+ * @param {number[]} out
4
+ * @param {number} out_offset where to start writing the result
5
+ * @param {number[]} input
6
+ * @param {number} input_offset where to start reading
7
+ * @param {number} count how many elements to use
8
+ * @returns {number[]} same as the `out` parameter, returned for convenience
9
+ */
10
+ export function v3_array_centroid(out: number[], out_offset: number, input: number[], input_offset: number, count: number): number[];
11
+ //# sourceMappingURL=v3_array_centroid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_array_centroid.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_array_centroid.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,uCAPW,MAAM,EAAE,cACR,MAAM,SACN,MAAM,EAAE,gBACR,MAAM,SACN,MAAM,GACJ,MAAM,EAAE,CA8BpB"}
@@ -0,0 +1,40 @@
1
+ import { assert } from "../../assert.js";
2
+
3
+ /**
4
+ * Compute average-weighted centroid of a set of 3d vectors
5
+ * @param {number[]} out
6
+ * @param {number} out_offset where to start writing the result
7
+ * @param {number[]} input
8
+ * @param {number} input_offset where to start reading
9
+ * @param {number} count how many elements to use
10
+ * @returns {number[]} same as the `out` parameter, returned for convenience
11
+ */
12
+ export function v3_array_centroid(out, out_offset, input, input_offset, count) {
13
+ assert.isNonNegativeInteger(out_offset, 'out_offset');
14
+ assert.isNonNegativeInteger(input_offset, 'input_offset');
15
+ assert.isNonNegativeInteger(count, 'count');
16
+
17
+ let x = 0;
18
+ let y = 0;
19
+ let z = 0;
20
+
21
+ for (let i = 0; i < count; i++) {
22
+ const offset = input_offset + i * 3;
23
+
24
+ x += input[offset];
25
+ y += input[offset + 1];
26
+ z += input[offset + 2];
27
+ }
28
+
29
+ if (count > 0) { // avoid division by zero
30
+ x /= count;
31
+ y /= count;
32
+ z /= count;
33
+ }
34
+
35
+ out[out_offset] = x;
36
+ out[out_offset + 1] = y;
37
+ out[out_offset + 2] = z;
38
+
39
+ return out;
40
+ }