How to use RecastJSPlugin in version 5.13

the recast-detour version is 1.5.0

import * as Recast from 'recast-detour'
import { RecastJSPlugin } from '@babylonjs/core'

let recast = await Recast();
const navigationPlugin = new RecastJSPlugin(recast);

Then send an error:
Uncaught (in promise) TypeError: Cannot set properties of undefined (setting ‘Recast’)

how to use RecastJSPlugin?

try to import Recast from ‘recast-detour’ instead import * as Recast from ‘recast-detour’

Hello @zz_dz just checking in if you’re still having issues.

I met the same problem, when importing ‘recast-detour’ package,

import * as BABYLON from '@babylonjs/core'
import Recast from 'recast-detour

const recast = await Recast
const navigationPlugin = new BABYLON.RecastJSPlugin(recast)

the error is blow:

SyntaxError: The requested module '....XXX' does not provide an export named 'fileURLToPath'

It seems about the ES6 module input error. Accourding to this post, I change the first line of d.ts file. But not work it out.
Can someone show demo using recast-detour via NPM?

cc @RaananW and @Cedric

Any news on this? I am having the same issue

There is an open discussion about improving the recast-detour package here - Recast (recast-detour) working with react-native - #15 by RaananW

Thank you for the quick update @RaananW :slight_smile:, creating an ESM-Friendly version of the package should fix the issue in my case i believe (i am using Vite instead of Webpack, which doesn’t transpile modules in development mode)

2 Likes

Hi Yannis, by any chance, were you able to make it work with your setup (mine looks quite similar, using Vite through Quasar framework).

I have been stuck for days. I gave up seeking a clean solution waiting for the ESM friendly version of recast-detour, and I was convinced that I could make it work with a “dirty” solution, but I am not able do that neither…

Any help of clue will be really appreciated ! :pray: