Error after updating to Alpha 40 & updated recast.js

Hi, I noticed I got an error after trying the latest alpha (40) with the updated recast.js.

I get an error on this line:
const navPlugin = new BABYLON.RecastJSPlugin();

BJS - [15:35:52]: RecastJS is not ready. Please make sure you await Recast() before using the plugin.
Uncaught (in promise) TypeError: this.bjsRECAST.Vec3 is not a constructor
at new RecastJSPlugin (babylon.max.js:177643)

Not sure what changed and how to fix it? This ran without problems before…

Nevermind, just had to add await Recast() as the error stated, wasn’t sure where to add it.


May I ask how you fixed it? Having the same error but can’t get it to work?

Instead of using just this in my code:

const navPlugin = new BABYLON.RecastJSPlugin();

Provided you load the recast.js script in your HTML:
I had to first wait for the Recast function to complete, so the code needs to be changed to this, wrapped in an async function:

async function buildNav() {
    await Recast();
    console.log('recast loaded');
    const navPlugin = new BABYLON.RecastJSPlugin();
    console.log('nav plugin loaded');


cc @Cedric

Thank you, this got me further! I’ve also did the following to get the Recast import working (found this somewhere in the forums

// @ts-ignore
import Recast from "recast-detour"

Now the thing compiles but it hangs forever loading the page with not specific errormessage. Any ideas?

I’m not sure what the reason is, but for me building the navmesh takes a lot longer than before…
Perhaps yours is still building? Did you try just waiting for a long time to see if it finishes?

Edit: I removed the ‘solved’ flag from my post, since I’d like to wait for Cedric to check if I may have messed something up.

I waited a few minutes but nothing happened

@Censor There should be (almost) no difference in performance. Maybe I missed something with Emscripten. Do you have a PG I can try ?
@holger Same, do you have a PG I can check?

Ok, I see what I can do.

1 Like

So, I can reproduce. Not in a PG but in a local typescript project. I’ve forked and modified @RaananW 's babylonjs-webpack-es6. This is the change: recast init repro · blubberblah/babylonjs-webpack-es6@c1fbd74 · GitHub
Just clone the repo and do a npm install and npm start this should bring up the modified scene src/scenes/defaultWithTexture.ts
As you can see (hopefully), it just hangs forever. I guess I’m doing something fundamentally wrong :wink:

Let me take a look …

Hi @holger

I’ve published a new NPM package for recast-detour v1.4.0

Can you please try with updated version?

With latest version it works! Thank you @Cedric :slight_smile:


I believe there was another thread just started about the error I got (first post).
I’ll wait for the fix and try again, perhaps the issues will be gone and this thread can be closed.

By the way I really like what’s possible with recast and babylonJS :slight_smile: