Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

In DetourNavMesh.cpp the method addTile is defined as

dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, dtTileRef lastRef, dtTileRef* result)

In nav-mesh.d.ts the method addTile is defined as

addTile(navMeshData: UnsignedCharArray, flags: number, lastRef: number): {
status: number;
tileRef: number;
};

I seems to work but I don't understand this as dataSize is used/read in the method but not provided in the call.
Is this mismatch something I can ignore?

You must be logged in to vote

Replies: 4 comments

Comment options

Hi, to provide some context - some c++ APIs can be difficult to create javascript bindings for directly with emscripten's webidl binder, paricularly APIs that have output pointers like addTile.

To work around this, this library adds some wrapper code so signatures are compatible with emscripten's webidl binder.

In this case, the addTile has this wrapper, using a "UnsignedIntRef" class in place of dtTileRef so it is bind-able. see:

I'm not sure if emscripten's embind javascript binder makes this simpler - but it certainly was a bit painful creating these wrappers for emscriptens webidl binder!

You must be logged in to vote
0 replies
Comment options

Hi. Thanks for your comments. I still don't understand why "datasize" is not part of the wrapper https://github.com/isaac-mason/recast-navigation-js/blob/main/packages/recast-navigation-wasm/src/NavMesh.h#L63 , but that doesn't matter as it works. I really appreciate your work. We are working on a cross-platform (Unity and Switft/Java native) implementation and I am able to use the (export) output from this web port in https://github.com/ikpil/DotRecast (with some minor adjustings as the c# port interprets the output as 64bit). So thank you for your work, it is really appreciated!

You must be logged in to vote
0 replies
Comment options

Hi, that is just because in this wrapper the navMeshData is a UnsignedCharArray class that contains a size. This is where the upstream library addTile is called: https://github.com/isaac-mason/recast-navigation-js/blob/main/packages/recast-navigation-wasm/src/NavMesh.cpp#L19

You must be logged in to vote
0 replies
Comment options

Glad you found this useful 🙂

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #473 on July 05, 2025 10:56.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.