@thi.ng/boids 1.0.32 → 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 +1 -1
- 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 +2 -4
- package/flock.js +1 -2
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
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
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/boids",
|
|
3
|
-
"version": "1.0.
|
|
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.
|
|
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": "^2.3.
|
|
44
|
-
"@thi.ng/math": "^5.10.
|
|
45
|
-
"@thi.ng/timestep": "^0.5.
|
|
46
|
-
"@thi.ng/vectors": "^7.10.
|
|
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.
|
|
50
|
-
"esbuild": "^0.
|
|
51
|
-
"typedoc": "^0.25.
|
|
52
|
-
"typescript": "^5.4.
|
|
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": "
|
|
146
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
147
147
|
}
|