@woosh/meep-engine 2.126.53 → 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.53",
8
+ "version": "2.126.54",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -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
+ }