@thi.ng/boids 1.0.31 → 1.0.33

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-04-23T07:02:17Z
3
+ - **Last updated**: 2024-05-08T18:24:31Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/accel.js CHANGED
@@ -5,8 +5,7 @@ const noAccel = () => {
5
5
  boids = $boids;
6
6
  },
7
7
  queryNeighborhood(neighborhood) {
8
- for (let b of boids)
9
- neighborhood.consider(b.pos.curr, b);
8
+ for (let b of boids) neighborhood.consider(b.pos.curr, b);
10
9
  return neighborhood;
11
10
  }
12
11
  };
@@ -11,8 +11,7 @@ const alignment = (maxDist, weight = 1) => {
11
11
  setN(force, 0);
12
12
  for (let i = 0; i < num; i++) {
13
13
  const n = neighbors[i];
14
- if (n !== boid)
15
- add(force, force, n.vel.curr);
14
+ if (n !== boid) add(force, force, n.vel.curr);
16
15
  }
17
16
  return boid.computeSteer(force, num - 1);
18
17
  }
@@ -11,8 +11,7 @@ const cohesion = (maxDist, weight = 1) => {
11
11
  setN(centroid, 0);
12
12
  for (let i = 0; i < num; i++) {
13
13
  const n = neighbors[i];
14
- if (n !== boid)
15
- add(centroid, centroid, n.pos.curr);
14
+ if (n !== boid) add(centroid, centroid, n.pos.curr);
16
15
  }
17
16
  return num > 1 ? boid.steerTowards(mulN(centroid, centroid, 1 / (num - 1))) : centroid;
18
17
  }
@@ -7,8 +7,7 @@ const dynamicTarget = (target, radius = Infinity, weight = 1) => {
7
7
  weight: __ensureFn(weight),
8
8
  update: (boid) => {
9
9
  currTarget = target(boid) || currTarget;
10
- if (!currTarget)
11
- return boid.api.ZERO;
10
+ if (!currTarget) return boid.api.ZERO;
12
11
  const r = $radius(boid);
13
12
  return boid.api.distSq(currTarget, boid.pos.curr) < r * r ? boid.steerTowards(currTarget, force) : boid.api.ZERO;
14
13
  }
@@ -3,8 +3,7 @@ const blendedBehaviorUpdate = (boid) => {
3
3
  const force = zeroes();
4
4
  for (let behavior of boid.behaviors) {
5
5
  const weight = behavior.weight(boid);
6
- if (weight !== 0)
7
- maddN(force, behavior.update(boid), weight, force);
6
+ if (weight !== 0) maddN(force, behavior.update(boid), weight, force);
8
7
  }
9
8
  return force;
10
9
  };
package/boid.js CHANGED
@@ -69,8 +69,7 @@ class Boid {
69
69
  */
70
70
  neighbors(r, pos) {
71
71
  const region = this.region;
72
- if (pos)
73
- region.target = pos;
72
+ if (pos) region.target = pos;
74
73
  region.setRadius(r);
75
74
  return this.accel.queryNeighborhood(region).deref();
76
75
  }
package/constrain.js CHANGED
@@ -13,8 +13,7 @@ const wrap2 = (min, max) => (p, boid) => {
13
13
  p[1] = wrapOnce(y, min[1], max[1]);
14
14
  wrap = true;
15
15
  }
16
- if (wrap)
17
- boid.pos.reset(p);
16
+ if (wrap) boid.pos.reset(p);
18
17
  return p;
19
18
  };
20
19
  const wrap3 = (min, max) => (p, boid) => {
@@ -32,8 +31,7 @@ const wrap3 = (min, max) => (p, boid) => {
32
31
  p[2] = wrapOnce(z, min[2], max[2]);
33
32
  wrap = true;
34
33
  }
35
- if (wrap)
36
- boid.pos.reset(p);
34
+ if (wrap) boid.pos.reset(p);
37
35
  return p;
38
36
  };
39
37
  export {
package/flock.js CHANGED
@@ -10,8 +10,7 @@ class Flock {
10
10
  }
11
11
  remove(boid) {
12
12
  const idx = this.boids.indexOf(boid);
13
- if (idx >= 0)
14
- this.boids.splice(idx, 1);
13
+ if (idx >= 0) this.boids.splice(idx, 1);
15
14
  }
16
15
  integrate(dt, ctx) {
17
16
  this.accel.build(this.boids);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/boids",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "n-dimensional boids simulation with modular behavior system",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -36,20 +36,20 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.1",
40
- "@thi.ng/checks": "^3.6.3",
41
- "@thi.ng/distance": "^2.4.71",
42
- "@thi.ng/geom-closest-point": "^2.1.125",
43
- "@thi.ng/geom-resample": "^2.3.51",
44
- "@thi.ng/math": "^5.10.12",
45
- "@thi.ng/timestep": "^0.5.47",
46
- "@thi.ng/vectors": "^7.10.29"
39
+ "@thi.ng/api": "^8.11.2",
40
+ "@thi.ng/checks": "^3.6.4",
41
+ "@thi.ng/distance": "^2.4.73",
42
+ "@thi.ng/geom-closest-point": "^2.1.127",
43
+ "@thi.ng/geom-resample": "^2.3.53",
44
+ "@thi.ng/math": "^5.10.13",
45
+ "@thi.ng/timestep": "^0.5.49",
46
+ "@thi.ng/vectors": "^7.10.31"
47
47
  },
48
48
  "devDependencies": {
49
- "@microsoft/api-extractor": "^7.43.0",
50
- "esbuild": "^0.20.2",
51
- "typedoc": "^0.25.12",
52
- "typescript": "^5.4.3"
49
+ "@microsoft/api-extractor": "^7.43.2",
50
+ "esbuild": "^0.21.1",
51
+ "typedoc": "^0.25.13",
52
+ "typescript": "^5.4.5"
53
53
  },
54
54
  "keywords": [
55
55
  "nd",
@@ -143,5 +143,5 @@
143
143
  "status": "alpha",
144
144
  "year": 2023
145
145
  },
146
- "gitHead": "5dd66c18a3862a3af69a5b2f49563f7cbdd960c2\n"
146
+ "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
147
147
  }