RecastPlugin with typescript error

Even though i read a lot of comments about the bug or the error in recast.js to avoid the problems. Unfortunately, I still got this problem. My project use Babylonjs V4.2.0 and recast-detour V1.4.0, the broswer throw some errors. I had not idea to fix it. :cold_sweat: :disappointed_relieved:

This is the error:

A repo will definitelly help here, however maybe someone more experienced with this plugin will spot the problem just by looking at the error message :slight_smile:
I had also some issues with the nav plugin but never saw this one particular error message so if you are able to share a repo with your setup I would like to have a look at it, it really interests me :vulcan_salute:

I am also getting this error

Most likely this error is related to parameters
but it is work by playground, is similarly no problem

navigationPlugin = new BABYLON.RecastJSPlugin(Recast);
let parameters = {
cs: 0.2,
ch: 0.2,
walkableSlopeAngle: 35,
walkableHeight: 1,
walkableClimb: 1,
walkableRadius: 1,
maxEdgeLen: 12.,
maxSimplificationError: 1.3,
minRegionArea: 8,
mergeRegionArea: 20,
maxVertsPerPoly: 6,
detailSampleDist: 6,
detailSampleMaxError: 1,
tileSize: 1,
borderSize: 1
navMesh.material = null;
let test= BABYLON.Mesh.MergeMeshes([navMesh]);
navigationPlugin.createNavMesh([test], parameters); ← error

my Development Environment is
@babylonjs/core”: “^4.2.0”,
“react”: “^17.0.2”,
“react-babylonjs”: “^3.0.22”,
“recast-detour”: “^1.3.0”,
“recastjs”: “^0.1.16”,
“redux”: “^4.1.1”,
“”: “^4.3.2”,
and babel 7.16

I believe this is @Cedric’s area of expertise. He will be back in a couple of days and I’m sure he’d be happy to take a look.

Usually when something works in the playground, but not in your project, it’s related to the packages you have installed locally.

Couple things to try:

  1. Updating to 5.0 in your project
  2. Downgrading the Playground to 4.2 (there’s a button in the top right for this)

Let me know if either resolves the issue. If not, if you could share a GitHub repo with your project, I can clone it on my end and poke around a bit.

i solved this problem
it was caused by navigationPlugin that is not conveyed correctly
and happen for the same reason(inner class constructor not understand navigationPlugin)
it is happen by the importing function LoadAssetContainer

I’ll try to reproduce this in playgruond and post a link.

BABYLON.SceneLoader.importMesh → BABYLON.SceneLoader.LoadAssetContainer
changed importing role


Thanks, i’m looking forward to your PG

hello @DWork here is pg, error or answer to problem
that are two case and are two types of each
case1 ErrorClass( constructor(navigationPlugin) and call this.navigationPlugin in method(not))
is two importing mesh and is not work because cannot be copied this.navigationPlugin
so next, case 2 RealClass ( constructor(not or other) and call navigationPlugin in method(navigationPlugin))
My problematic case was solved with this.

I think your problem is,
not copied navigationPlugin or nameshParameters are add two
→ tileSize: null,
→ borderSize: null
and to add help If you don’t call navigationPlugin anywhere else
use { let navigationPlugin =new RecastJPlugin(React) } instead of
{ if(this.navigationPlugin ===null ~ new RecastJPlugin(React) }