Skip to content
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

Custom Navigation Meshes #1077

Merged
merged 8 commits into from
Feb 12, 2021
Merged

Custom Navigation Meshes #1077

merged 8 commits into from
Feb 12, 2021

Conversation

robertlong
Copy link
Contributor

@robertlong robertlong commented Jan 14, 2021

You can now specify a model for a custom navigation mesh. In the Floor Plan element's properties panel change the floor plan mode to "Custom" and drag and drop a model into the "Custom Navmesh Url" field.

image

Fixes #1075

@robertlong robertlong added the whats new Include this PR on the "What's New" page label Jan 14, 2021
Copy link
Contributor

@netpro2k netpro2k left a comment

Choose a reason for hiding this comment

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

Made some minor suggestions and discussed some possible future enhancements, but lgtm

})()
);
} else {
node._navMeshSrc = navMeshSrc;
Copy link
Contributor

Choose a reason for hiding this comment

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

You might consider just assigning this above right after navMeshMode like:
node._navMeshSrc = navMeshSrc || ""

to get rid of the need for the nested if, and make the default value more explicit.

if (navMeshMode === NavMeshMode.Custom) {
loadAsync(
(async () => {
await node.load(navMeshSrc, onError);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the wrapping function? I think loadAsync(node.load(navMeshSrc, onError))should do the same thing assuming loadAsync just expects a promise.

this.setNavMesh(new Mesh(geometry, new MeshBasicMaterial({ color: 0x0000ff, transparent: true, opacity: 0.2 })));

if (this.navMesh) {
this.navMesh.visible = this.editor.selected.indexOf(this) !== -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? Guessing since you are emitting selectionChanged at the end of this function the state should already get updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it looks like onSelect() isn't called in response to the selectionChanged event 🤷‍♂️

</>
) : (
<InputGroup name="Custom Navmesh Url">
<ModelInput value={node.navMeshSrc} onChange={this.onChangeNavMeshSrc} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Not new to this PR, just anything taking a model in general so not something we need to address in this PR, but we might want to think about how we could visually indicate somehow that this field can have models dragged into it from assets. Ideally there might even be a little button on the field that pops up an asset picker (similar to how it works in Unity)

@robertlong robertlong merged commit 02c0a77 into master Feb 12, 2021
@robertlong robertlong deleted the feature/custom-nav-mesh branch February 12, 2021 01:07
@robertlong robertlong added whats new Include this PR on the "What's New" page and removed whats new Include this PR on the "What's New" page labels Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
whats new Include this PR on the "What's New" page
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for specifying a custom navmesh
2 participants