I need the navigation computed on the backend and the browser side just replay the path travel. It seems to be working mostly but not quite right.
Please take a look at my PG. https://playground.babylonjs.com/#WCSDE1#10
Line 59 and 60 are the baked navigation mesh data generated by the backend and browser, respectively. The array size are different. You can comment out either line to see the different behaviors. The baked nav mesh data generated in the browser works fine. But if the baked nav mesh data from backend is used, the cube is still able to walk through the obstacle. The cube cannot walk through the static obstacles in both cases, so I think the baked data from backend seems to be correct to some extent.
I followed this document to run babylon.js on the backend. Running Babylon.js On A Server | Babylon.js Documentation The code I used look like the following:
const BABYLON = require("../babylon/babylon.max"); const Recast = require('recast-detour')(); const engine = new BABYLON.NullEngine(); const scene = new BABYLON.Scene(engine); const mesh = createStaticMesh(scene); const navigationPlugin = new BABYLON.RecastJSPlugin(Recast); navigationPlugin.createNavMesh([mesh], parameters); const data = navigationPlugin.getNavmeshData();
Function createStaticMesh() and parameters variable used for the backend run are exactly the same as in the PG.