Recast-detour in typescript

i am trying to use recast in Babylon+React TypeScript. it is throwing below error

Could not find a declaration file for module ‘recast-detour’. ‘d:/Myden/DeftnTactWebsite/Demos/node_modules/recast-detour/recast.js’ implicitly has an ‘any’ type

Adding @Cedric the mastermind behind the integration

I guess it needs a definition file for types description? I have no idea how to write or generate one. Any link/documentation page @sebavan

Ouch… yup you would need to create your own definition file :frowning: so either it is all TS code and you can generate it or you need to write it by hand:

And I usually copy paste section of the babylon one to do that but it is tedious and maintenance hell :slight_smile:

1 Like

@Krishna_Kishore

I think you can generate the .d.ts using GitHub - giniedp/webidl2ts: Converts Web IDL to Typescript (.d.ts)
with a command like:

webidl2ts -i  https://raw.githubusercontent.com/BabylonJS/Extensions/master/recastjs/recast.idl  -o recast.d.ts

i installed using webidl2ts i get below error. if you are able to generate can you please share the file

webidl2ts : The term ‘webidl2ts’ is not recognized as the name of a cmdlet, function, script file,

you didn’t install webidl2ts with the -g parameter to make it global.
I did generate the .d.ts : recast.d.ts by CedricGuillemet · Pull Request #9544 · BabylonJS/Babylon.js · GitHub
Can you please @Krishna_Kishore check that it works for you. If so, I’ll add it to recast .npm

i am getting below error

File ‘node_modules/recast-detour/recast.d.ts’ is not a module.

I’ve updated the PR, please try with my new changes. Sorry for the iterations, it might take 1 or 2 more :slight_smile:

now i am able to use the type script , thanks for your help.

i have one more question, is there a way we can have call back agentGoto once agent reaches the point

for example i have person who follow the camera, once he reaches the point, he should stop the walking animation and look at the camera

That’s great news!

It’s possible but this brings a lot of potential issues that have to be treated specifically.
I prefer to let users code their logic.
For example, agent may never reach exactly the destination point. It will get close enough eventually but you have to provide a radius. This can happen because of upcoming obstacles or having multiple agents trying to reach the same point.
Maybe user will add some timeout, variable radius and so on.
As the library can’t handle every cases, I prefer to node provide a solution.

i am able to generate nav mesh, but the SM_Project_Base mesh is not blocked in the nav mesh which is generated. please find the glb below

https://3dspaces.blob.core.windows.net/spaces/demos/aparnapoc/MainMap.glb.

here are my parameters to generate the navigation, can you please let me what i am doing is wrong
var navmeshParameters = {
cs: 1,
ch: 1,
walkableSlopeAngle: 35,
walkableHeight: 2,
walkableClimb: 1,
walkableRadius: 1,
maxEdgeLen: 12.,
maxSimplificationError: 1.3,
minRegionArea: 8,
mergeRegionArea: 20,
maxVertsPerPoly: 6,
detailSampleDist: 6,
detailSampleMaxError: 1,
};

var mesh = scene.getMeshByName("SM_Floor") as Mesh
var projectBase = scene.getMeshByName("SM_Project_Base") as Mesh

navigationPlugin.createNavMesh([mesh!,projectBase!,miniature!], navmeshParameters);

I’m trying to repro …

It works for me :

glb NavMesh | Babylon.js Playground

I guess you didn’t create the navmesh once the .glb is loaded.

can you try for adding this “SM_Project_Base”.

Here you are :
glb NavMesh | Babylon.js Playground

Note: “SM_Project_Base” didn’t touch the ground, I had to push it a little bit downward.

worked , thanks you are awesome…

i got the point, most of the case wether agent is reached the point or not, once the agent to reaches the target or nearest , the call back is important,

reason being, client want to do some once agent reaches or nearest , in my case i want the agent to point towards the camera and talk some thing once the agent reaches the nearest point.