recast-navigation 0.28.0 → 0.29.1

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.
Files changed (2) hide show
  1. package/README.md +61 -16
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -58,10 +58,10 @@ You can use import maps to use the library without a bundler:
58
58
  <script type="importmap">
59
59
  {
60
60
  "imports": {
61
- "@recast-navigation/core": "https://unpkg.com/@recast-navigation/core@0.27.0/dist/index.mjs",
62
- "@recast-navigation/wasm": "https://unpkg.com/@recast-navigation/wasm@0.27.0/dist/recast-navigation.wasm-compat.js",
63
- "@recast-navigation/generators": "https://unpkg.com/@recast-navigation/generators@0.27.0/dist/index.mjs",
64
- "@recast-navigation/three": "https://unpkg.com/@recast-navigation/three@0.27.0/dist/index.mjs"
61
+ "@recast-navigation/core": "https://unpkg.com/@recast-navigation/core@0.29.0/dist/index.mjs",
62
+ "@recast-navigation/wasm": "https://unpkg.com/@recast-navigation/wasm@0.29.0/dist/recast-navigation.wasm-compat.js",
63
+ "@recast-navigation/generators": "https://unpkg.com/@recast-navigation/generators@0.29.0/dist/index.mjs",
64
+ "@recast-navigation/three": "https://unpkg.com/@recast-navigation/three@0.29.0/dist/index.mjs"
65
65
  }
66
66
  }
67
67
  </script>
@@ -220,6 +220,51 @@ const maxAgentRadius = 0.6;
220
220
  const crowd = new Crowd(navMesh, { maxAgents, maxAgentRadius });
221
221
  ```
222
222
 
223
+ **Updating a Crowd**
224
+
225
+ There are a few options for updating a crowd:
226
+
227
+ **Variable time stepping**
228
+
229
+ The simplest approach is to do varible time stepping. Simply call `crowd.update` with your delta time every frame.
230
+
231
+ ```ts
232
+ crowd.update(timeSinceLastFrame);
233
+ ```
234
+
235
+ This approach is suitable for most use cases, but the variable timestep will result in non-deterministic behaviour.
236
+
237
+ Depending on your use case, you might want to clamp `timeSinceLastFrame` to a maximum value to prevent large time steps causing issues.
238
+
239
+ **Fixed time stepping with interpolation**
240
+
241
+ Fixed time stepping with interpolation can be preferable if you need deterministic behaviour, but still want smooth agent position updates each frame.
242
+
243
+ If you provide `update` with a `dt` value and a `timeSinceLastFrame` value, the crowd update will do fixed time stepping with interpolation.
244
+
245
+ ```ts
246
+ const dt = 1 / 60;
247
+ const maxSubSteps = 10;
248
+
249
+ crowd.update(dt, timeSinceLastFrame, maxSubSteps);
250
+ ```
251
+
252
+ This will update the `interpolatedPosition` vector3 on each agent, which you can use to render a smoothly interpolated agent position between updates.
253
+
254
+ ```ts
255
+ console.log(agent.interpolatedPosition); // { x: 1, y: 2, z: 3 }
256
+ ```
257
+
258
+ **Manual fixed time stepping**
259
+
260
+ If you want full control over crowd updates, you can simply call `crowd.update` with a given `dt` value.
261
+
262
+ ```ts
263
+ const dt = 1 / 60;
264
+
265
+ crowd.update(dt);
266
+ ```
267
+
223
268
  **Creating an Agent in a Crowd**
224
269
 
225
270
  ```ts
@@ -257,18 +302,6 @@ agent.requestMoveTarget(targetPosition);
257
302
  agent.resetMoveTarget();
258
303
  ```
259
304
 
260
- **Updating the Crowd**
261
-
262
- To update the crowd, first set a timeStep, then call `update` each frame with the delta time.
263
-
264
- ```ts
265
- const dt = 1 / 60;
266
- crowd.timeStep = dt;
267
-
268
- // you should call this every frame
269
- crowd.update(dt);
270
- ```
271
-
272
305
  **Interacting with Agents**
273
306
 
274
307
  ```ts
@@ -581,6 +614,18 @@ Helpers for three.js.
581
614
  > npm install @recast-navigation/three
582
615
  ```
583
616
 
617
+ ### [**`@recast-navigation/wasm`**](https://github.com/isaac-mason/recast-navigation-js/tree/main/packages/recast-navigation-wasm)
618
+
619
+ [![Version](https://img.shields.io/npm/v/@recast-navigation/wasm)](https://www.npmjs.com/package/@recast-navigation/wasm)
620
+
621
+ The WebAssembly build of the Recast and Detour libraries.
622
+
623
+ You regularly won't need to use this package directly, as `@recast-navigation/core` uses it internally.
624
+
625
+ ```bash
626
+ > npm install @recast-navigation/wasm
627
+ ```
628
+
584
629
  ## Apps
585
630
 
586
631
  ### [NavMesh Generator](https://navmesh.isaacmason.com/)
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "email": "isaac@isaacmason.com",
19
19
  "url": "https://isaacmason.com/"
20
20
  },
21
- "version": "0.28.0",
21
+ "version": "0.29.1",
22
22
  "license": "MIT",
23
23
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
24
24
  "bugs": {
@@ -67,9 +67,9 @@
67
67
  "lint": "eslint --ext .ts src"
68
68
  },
69
69
  "dependencies": {
70
- "@recast-navigation/core": "0.28.0",
71
- "@recast-navigation/generators": "0.28.0",
72
- "@recast-navigation/three": "0.28.0"
70
+ "@recast-navigation/core": "0.29.1",
71
+ "@recast-navigation/generators": "0.29.1",
72
+ "@recast-navigation/three": "0.29.1"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@babel/core": "^7.24.5",
@@ -79,7 +79,7 @@
79
79
  "@mdx-js/react": "^2.3.0",
80
80
  "@pmndrs/assets": "^1.6.0",
81
81
  "@react-three/drei": "^9.105.4",
82
- "@react-three/fiber": "^8.15.12",
82
+ "@react-three/fiber": "^8.16.3",
83
83
  "@rollup/plugin-babel": "^6.0.4",
84
84
  "@rollup/plugin-commonjs": "^25.0.7",
85
85
  "@rollup/plugin-node-resolve": "^15.0.1",