-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load nav-mesh only once #6326
Load nav-mesh only once #6326
Conversation
if (navMeshEid) { | ||
inflatePhysicsShape(world, navMeshEid, { | ||
if (isHighDensity && navMesh) { | ||
inflatePhysicsShape(world, navMesh.eid!, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Can't navMeshEid
be used here instead of navMesh
and navMesh.eid!
?
if (isHighDensity && navMeshEid) {
inflatePhysicsShape(world, navMeshEid, {
If it can be, navMesh
can be scoped into the if
block above.
if (navMeshEid) {
const navMeshObj = world.eid2obj.get(navMeshEid);
// TODO the "as any" here is because of incorrect type definition for getObjectByProperty. It was fixed in r145
const navMesh = navMeshObj?.getObjectByProperty("isMesh", true as any) as Mesh;
// Some older scenes have the nav-mesh component as an ancestor of the mesh itself
if (navMesh !== navMeshObj) {
console.warn("The `nav-mesh` component should be placed directly on a mesh.");
}
sceneEl.systems.nav.loadMesh(navMesh, "character");
}
I think it's ok to load nav mesh only once per a scene, especially if the behavior is same as the one with the A-Frame based implementation. I want to make clear one thing. Is having multiple nav meshes in a scene valid? If invalid, the blender add-on may need to be updated to block to export, too (I assumes they are set up with the blender add-on). If valid, we may need inline TODO comment about supporting multiple nav meshes in the future and console warning that we ignore other nav meshes for now. |
No, it's not, we only support one nav mesh per scene. I've opened an issues to show a warning when there is more than one object with a nav-mesh component: Hubs-Foundation/hubs-blender-exporter#245 |
Addresses #6316 (comment)
In AFrame the nav mesh load was happening only once for the first found nav-mesh component:
https://github.com/mozilla/hubs/blob/f15d84aa019c0b2dfa34be8c91c9b82a6bad1c58/src/systems/environment-system.js#L137-L140
For the new loader we were loading the nav-mesh while traversing the scene so if multiple nav meshes were found we were effectively using the last traversed one.
This PR changes that behavior so we only process the nav-mesh once.