RecastJSPlugin, Typescript, ES6

Hello!

If you couldn’t get this setup working, because you were not able to import Recast always getting ‘File is not a module error’, than follow this:

npm i recast-detour

Open node_modules/recast-detour/recast.d.ts and edit the first line

Change declare module Recast to export namespace Recast

After this you can simply:

import * as Recast from 'recast-detour'

You need to import { RecastJSPlugin } from '@babylonjs/core' to get the whole thing working, obviously…

Pass Recast to the plugin this way: const navigationPlugin = new RecastJSPlugin(Recast)

OR JUST

const Recast = require('recast-detour'), but the linter will complain, that you need to change it to an ES6 import. Hopefully you all know how to silence it :smiley: However I prefer not to mix imports and requires, so the industry does, therefore I highly encourage you to use the first longer but much cleaner method.

Enjoy!

EDIT:
https://github.com/Microsoft/TypeScript/issues/13774

R.

1 Like

awesome, thanks for sharing

1 Like

Ping @Cedric FYI

1 Like