Skip to content

Conversation

RolandCsibrei
Copy link
Contributor

@RolandCsibrei RolandCsibrei commented Aug 16, 2025

Already working examples (I need to tide up the code a bit):
http://localhost:1338/#KVQP83#203 = navmesh generation stuff
http://localhost:1338/#KVQP83#209 = obstacles
http://localhost:1338/#KVQP83#213 = offmesh
http://localhost:1338/#KVQP83#245 = move along navmesh with WASD
http://localhost:1338/#KVQP83#244 = raycast

@RolandCsibrei RolandCsibrei marked this pull request as draft August 16, 2025 22:03
@bjsplat
Copy link
Collaborator

bjsplat commented Aug 16, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 16, 2025

Reviewer - this PR has made changes to one or more package.json files.

@RolandCsibrei
Copy link
Contributor Author

RolandCsibrei commented Aug 16, 2025

Hello!
Finally it's here :-)
I have a few questions:

At this point we support all the V1 plugin functions + offMeshConnections. These are some enhacements beyond V1:

  • Optimizations can be done by switching to IVector3Like instead of Vector3 - could break backward comaptibility
  • Crowd - inject custom update function
  • Add extents as a parameter to plugin functions
  • Add more observables (OverOffMeshConnection)
  • Inject custom TileCacheMeshProcess
  • Support Areas, Flags (this allows to set certain polys as water, sand, etc...)
  • Add userId support - each agent could have an userId. Some Recast functions can treat different users differently (some users can use the teleports, some must avoid the obstacle, some mustn't, etc...)
  • Implement all debug layers
  • [ ]
    There still some TODOs I need to resolve.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 16, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 16, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 17, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 20, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 20, 2025

Reviewer - this PR has made changes to one or more package.json files.

added TODO
@bjsplat
Copy link
Collaborator

bjsplat commented Aug 20, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 20, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 20, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 20, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 22, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 22, 2025

Reviewer - this PR has made changes to one or more package.json files.

/**
*
*/
export interface INavigationEnginePluginV2 extends INavigationEnginePlugin {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say lets just remove the v2 interface, and just have the new concrete class that also implements the v1 interface (as it already does).

@@ -89,3 +89,5 @@ export * from "../ShadersWGSL/rgbdEncode.fragment";
// CopyTextureToTexture
export * from "../Shaders/copyTextureToTexture.fragment";
export * from "../ShadersWGSL/copyTextureToTexture.fragment";

export * from "./tools.internals";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert? Doesn't seem necessary, especially since you are importing directly from the path anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not exported it's not visible in the ADDONS package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of UMD? @deltakosh, @sebavan - it seems like we shouldn't export internal tools from the core package, any thoughts?

* The navmesh query created from the navmesh
* @remarks This is used to query the navmesh for pathfinding and other navigation tasks
*/
public navMeshQuery!: NavMeshQuery;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this nullable? It's not assigned until some functions get called, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The navMeshQuery gets created automatically when the navMesh is generated. If navMesh generation fails an error is thrown so basically you can't do anything with the plugin. navMeshQuery is used in a lot of functions (called in the render-loop) and checking for non-null value would be a performance bottleneck.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is the idea that you construct the object and then you must call either buildFromNavmeshData or createNavMesh? If so, is the object in an invalid state after construction but before one of these functions are called? Once you call one of these functions, can you call either one of them subsequently on the same instance?

import { GenerateNavMesh } from "../generator";
import type { RecastNavigationJSPluginV2 } from "../plugin/RecastNavigationJSPlugin";

export let BjsRecast: RecastInjection;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should be nullable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about this one. I agree that it's not the best practice to leave variables unitialized but this one is maybe an exception. It must be initialized during the init process otherwise the nav engine will not be operational. If I make it nullable, there must be checks for non-null value before using the variable howvever if something fails upon init it makes no sense to access it. I'm not arguing here just loudly thinking. If you still want me to make it nullable, no problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about exporting an accessor function instead (like GetBjsRecast or something) that is synchronous but throws if the value is not set. Then you'd just have a nullable local module scoped variable (which is correctly typed), and usages of it don't need to do any checks or asynchrony, it will just throw if it is null. It's effectively a runtime assertion to protect against programming errors.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 23, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 23, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 24, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 24, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 25, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Aug 25, 2025

Reviewer - this PR has made changes to one or more package.json files.

@RolandCsibrei
Copy link
Contributor Author

@ryantrem since the options parameter is for several functions the same I'll introduce a type for it

navMeshQuery: NavMeshQuery;
tileCache?: TileCache;
}>((resolve, _reject) => {
GenerateNavMeshWithWorker(meshes, parameters, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like GenerateNavMeshWithWorker can synchronously throw, but there is no try/catch with a call to _reject. I think that should be added if I'm reading the code correctly.

// callback function to process the message from the worker
workerOptions.worker.onmessage = (e) => {
if ((e as any).data?.success === false) {
throw new Error(`Unable to generate navMesh: ${e}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these errors go? I assume they just show up as console errors, and the promise on the other side of this never resolves or rejects?

Comment on lines +15 to +16
const positions = [];
const indices = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are untyped.

Suggested change
const positions = [];
const indices = [];
const positions: number[] = [];
const indices: number[] = [];

continue;
}

const worldMatrices = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const worldMatrices = [];
const worldMatrices: Matrix[] = [];

/**
* The error message if the path computation failed.
*/
error?: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't error still only valid/present when sucess is false? Still seems like this could be a discriminated union to be more clear, unless it causes some problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants