@thi.ng/boids 1.0.32 → 1.0.34
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 +7 -1
- package/README.md +2 -2
- package/accel.js +1 -2
- package/behaviors/alignment.js +1 -2
- package/behaviors/cohesion.js +1 -2
- package/behaviors/dynamic.js +1 -2
- package/behaviors/update.js +1 -2
- package/boid.js +1 -2
- package/constrain.js +8 -26
- package/flock.js +1 -2
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
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.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [1.0.34](https://github.com/thi-ng/umbrella/tree/@thi.ng/boids@1.0.34) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- dedupe wrap2/3() internals ([6ca4b99](https://github.com/thi-ng/umbrella/commit/6ca4b99))
|
|
17
|
+
|
|
12
18
|
### [1.0.30](https://github.com/thi-ng/umbrella/tree/@thi.ng/boids@1.0.30) (2024-04-20)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -111,7 +111,7 @@ For Node.js REPL:
|
|
|
111
111
|
const boids = await import("@thi.ng/boids");
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
114
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.91 KB
|
|
115
115
|
|
|
116
116
|
## Dependencies
|
|
117
117
|
|
package/accel.js
CHANGED
package/behaviors/alignment.js
CHANGED
|
@@ -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
|
}
|
package/behaviors/cohesion.js
CHANGED
|
@@ -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
|
}
|
package/behaviors/dynamic.js
CHANGED
|
@@ -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
|
}
|
package/behaviors/update.js
CHANGED
|
@@ -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
package/constrain.js
CHANGED
|
@@ -2,37 +2,19 @@ import { wrapOnce } from "@thi.ng/math/interval";
|
|
|
2
2
|
import { clamp2 as $clamp2, clamp3 as $clamp3 } from "@thi.ng/vectors/clamp";
|
|
3
3
|
const clamp2 = (min, max) => (p) => $clamp2(p, p, min, max);
|
|
4
4
|
const clamp3 = (min, max) => (p) => $clamp3(p, p, min, max);
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
p[0] = wrapOnce(x, min[0], max[0]);
|
|
10
|
-
wrap = true;
|
|
11
|
-
}
|
|
12
|
-
if (y < min[1] || y > max[1]) {
|
|
13
|
-
p[1] = wrapOnce(y, min[1], max[1]);
|
|
14
|
-
wrap = true;
|
|
5
|
+
const __wrap = (p, i, x, min, max) => {
|
|
6
|
+
if (x < min || x > max) {
|
|
7
|
+
p[i] = wrapOnce(x, min, max);
|
|
8
|
+
return true;
|
|
15
9
|
}
|
|
16
|
-
|
|
10
|
+
};
|
|
11
|
+
const wrap2 = (min, max) => (p, boid) => {
|
|
12
|
+
if (__wrap(p, 0, p[0], min[0], max[0]) || __wrap(p, 1, p[1], min[1], max[1]))
|
|
17
13
|
boid.pos.reset(p);
|
|
18
14
|
return p;
|
|
19
15
|
};
|
|
20
16
|
const wrap3 = (min, max) => (p, boid) => {
|
|
21
|
-
|
|
22
|
-
let wrap = false;
|
|
23
|
-
if (x < min[0] || x > max[0]) {
|
|
24
|
-
p[0] = wrapOnce(x, min[0], max[0]);
|
|
25
|
-
wrap = true;
|
|
26
|
-
}
|
|
27
|
-
if (y < min[1] || y > max[1]) {
|
|
28
|
-
p[1] = wrapOnce(y, min[1], max[1]);
|
|
29
|
-
wrap = true;
|
|
30
|
-
}
|
|
31
|
-
if (z < min[2] || z > max[2]) {
|
|
32
|
-
p[2] = wrapOnce(z, min[2], max[2]);
|
|
33
|
-
wrap = true;
|
|
34
|
-
}
|
|
35
|
-
if (wrap)
|
|
17
|
+
if (__wrap(p, 0, p[0], min[0], max[0]) || __wrap(p, 1, p[1], min[1], max[1]) || __wrap(p, 2, p[2], min[2], max[2]))
|
|
36
18
|
boid.pos.reset(p);
|
|
37
19
|
return p;
|
|
38
20
|
};
|
package/flock.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/boids",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"description": "n-dimensional boids simulation with modular behavior system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/boids",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -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.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/distance": "^2.4.
|
|
42
|
-
"@thi.ng/geom-closest-point": "^2.1.
|
|
43
|
-
"@thi.ng/geom-resample": "^
|
|
44
|
-
"@thi.ng/math": "^5.
|
|
45
|
-
"@thi.ng/timestep": "^0.5.
|
|
46
|
-
"@thi.ng/vectors": "^7.
|
|
39
|
+
"@thi.ng/api": "^8.11.3",
|
|
40
|
+
"@thi.ng/checks": "^3.6.5",
|
|
41
|
+
"@thi.ng/distance": "^2.4.74",
|
|
42
|
+
"@thi.ng/geom-closest-point": "^2.1.128",
|
|
43
|
+
"@thi.ng/geom-resample": "^3.0.0",
|
|
44
|
+
"@thi.ng/math": "^5.11.0",
|
|
45
|
+
"@thi.ng/timestep": "^0.5.50",
|
|
46
|
+
"@thi.ng/vectors": "^7.11.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@microsoft/api-extractor": "^7.
|
|
50
|
-
"esbuild": "^0.
|
|
51
|
-
"typedoc": "^0.25.
|
|
52
|
-
"typescript": "^5.
|
|
49
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
50
|
+
"esbuild": "^0.21.5",
|
|
51
|
+
"typedoc": "^0.25.13",
|
|
52
|
+
"typescript": "^5.5.2"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"nd",
|
|
@@ -143,5 +143,5 @@
|
|
|
143
143
|
"status": "alpha",
|
|
144
144
|
"year": 2023
|
|
145
145
|
},
|
|
146
|
-
"gitHead": "
|
|
146
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
147
147
|
}
|