@thi.ng/boids 1.1.3 → 1.1.5
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 +8 -1
- package/README.md +1 -1
- package/behaviors/update.d.ts +1 -2
- package/behaviors/update.js +8 -3
- package/boid.d.ts +5 -0
- package/boid.js +6 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-05-
|
|
3
|
+
- **Last updated**: 2025-05-18T17:03:01Z
|
|
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.
|
|
@@ -11,6 +11,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
11
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
12
|
and/or version bumps of transitive dependencies.
|
|
13
13
|
|
|
14
|
+
### [1.1.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/boids@1.1.4) (2025-05-12)
|
|
15
|
+
|
|
16
|
+
#### ⏱ Performance improvements
|
|
17
|
+
|
|
18
|
+
- add Boid.force, update blendedBehaviorUpdate() ([dbb3178](https://github.com/thi-ng/umbrella/commit/dbb3178))
|
|
19
|
+
- pre-allocate force vector to avoid re-allocations for every frame
|
|
20
|
+
|
|
14
21
|
### [1.1.3](https://github.com/thi-ng/umbrella/tree/@thi.ng/boids@1.1.3) (2025-05-09)
|
|
15
22
|
|
|
16
23
|
#### 🩹 Bug fixes
|
package/README.md
CHANGED
package/behaviors/update.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Vec } from "@thi.ng/vectors";
|
|
2
1
|
import type { Boid } from "../boid.js";
|
|
3
2
|
/**
|
|
4
3
|
* Behavior update function (the default implementation fro
|
|
@@ -10,5 +9,5 @@ import type { Boid } from "../boid.js";
|
|
|
10
9
|
*
|
|
11
10
|
* @param boid
|
|
12
11
|
*/
|
|
13
|
-
export declare const blendedBehaviorUpdate: (boid: Boid) => Vec<number>;
|
|
12
|
+
export declare const blendedBehaviorUpdate: (boid: Boid) => import("@thi.ng/vectors").Vec<number>;
|
|
14
13
|
//# sourceMappingURL=update.d.ts.map
|
package/behaviors/update.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
const blendedBehaviorUpdate = (boid) => {
|
|
2
|
-
const {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const {
|
|
3
|
+
api: { maddN, setN },
|
|
4
|
+
behaviors,
|
|
5
|
+
force
|
|
6
|
+
} = boid;
|
|
7
|
+
setN(force, 0);
|
|
8
|
+
for (let i = 0, n = behaviors.length; i < n; i++) {
|
|
9
|
+
const behavior = behaviors[i];
|
|
5
10
|
const weight = behavior.weight(boid);
|
|
6
11
|
if (weight !== 0) maddN(force, behavior.update(boid), weight, force);
|
|
7
12
|
}
|
package/boid.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ export declare class Boid implements ITimeStep {
|
|
|
12
12
|
behaviors: IBoidBehavior[];
|
|
13
13
|
region: Radial<Boid>;
|
|
14
14
|
opts: BoidOpts;
|
|
15
|
+
/**
|
|
16
|
+
* Pre-allocated vector for force accumulation, used by/for behavior
|
|
17
|
+
* updates.
|
|
18
|
+
*/
|
|
19
|
+
force: Vec;
|
|
15
20
|
constructor(opts: BoidOpts, api: VecAPI, distance: IDistance<ReadonlyVec>, pos: Vec, vel: Vec);
|
|
16
21
|
/**
|
|
17
22
|
* Integration step of the thi.ng/timestep update cycle. See
|
package/boid.js
CHANGED
|
@@ -14,6 +14,11 @@ class Boid {
|
|
|
14
14
|
behaviors;
|
|
15
15
|
region;
|
|
16
16
|
opts;
|
|
17
|
+
/**
|
|
18
|
+
* Pre-allocated vector for force accumulation, used by/for behavior
|
|
19
|
+
* updates.
|
|
20
|
+
*/
|
|
21
|
+
force;
|
|
17
22
|
constructor(opts, api, distance, pos, vel) {
|
|
18
23
|
this.api = api;
|
|
19
24
|
this.opts = { maxForce: 1, ...opts };
|
|
@@ -33,6 +38,7 @@ class Boid {
|
|
|
33
38
|
(pos2, dt) => constrain(maddN(pos2, this.vel.curr, dt, pos2), this)
|
|
34
39
|
);
|
|
35
40
|
this.region = new Radial(distance, pos, 1);
|
|
41
|
+
this.force = api.zeroes();
|
|
36
42
|
}
|
|
37
43
|
/**
|
|
38
44
|
* Integration step of the thi.ng/timestep update cycle. See
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/boids",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "n-dimensional boids simulation with modular behavior system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@thi.ng/api": "^8.11.27",
|
|
43
43
|
"@thi.ng/checks": "^3.7.7",
|
|
44
|
-
"@thi.ng/distance": "^2.4.
|
|
45
|
-
"@thi.ng/geom-closest-point": "^2.1.
|
|
46
|
-
"@thi.ng/geom-resample": "^3.0.
|
|
44
|
+
"@thi.ng/distance": "^2.4.119",
|
|
45
|
+
"@thi.ng/geom-closest-point": "^2.1.173",
|
|
46
|
+
"@thi.ng/geom-resample": "^3.0.45",
|
|
47
47
|
"@thi.ng/math": "^5.11.27",
|
|
48
|
-
"@thi.ng/timestep": "^1.0.
|
|
49
|
-
"@thi.ng/vectors": "^8.
|
|
48
|
+
"@thi.ng/timestep": "^1.0.21",
|
|
49
|
+
"@thi.ng/vectors": "^8.2.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"esbuild": "^0.25.3",
|
|
@@ -147,5 +147,5 @@
|
|
|
147
147
|
"status": "alpha",
|
|
148
148
|
"year": 2023
|
|
149
149
|
},
|
|
150
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "99ea3cda41e61b66f3914c5c9c9b7bb60ee3ee84\n"
|
|
151
151
|
}
|