Comments (5)
Hi @6ther!
Something you could try is passing computePath
the results from navMeshQuery.getClosestPoint
, for example:
const path = navMeshQuery.computePath(
navMeshQuery.getClosestPoint({ x: -88.92649, y: 0, z: -84.2824}), // start position
navMeshQuery.getClosestPoint({ x: 173.07352, y: 0, z: -131.28241 }) // end position
);
Also, do you mind sharing the file you uploaded to navmesh.isaacmason.com so I can test with that as well?
The geometry I've created using the positions and indices provided looks different:
Let me know if I'm doing something silly.
from recast-navigation-js.
planeXunlu.txt
const path = navMeshQuery.computePath( navMeshQuery.getClosestPoint({ x: 88.92649, y: 0, z: -84.2824}), // start position navMeshQuery.getClosestPoint({ x: -173.07352, y: 0, z: -131.28241 }) // end position );
{ x: -88.92649, y: 0, z: -84.2824},{ x: 173.07352, y: 0, z: -131.28241 } these points is not in NavMesh, so the path is empty.
But I try another points:{ x: 88.92649, y: 0, z: -84.2824},{ x: -173.07352, y: 0, z: -131.28241 },
the path is
[
(88.72650146484375, 0.20000000298023224, -84.08241271972656),
(26.5264892578125, 0.20000000298023224, -56.882408142089844),
(3.1264801025390625, 0.20000000298023224, -46.682411193847656),
(1.7264862060546875, 0.20000000298023224, -46.08240509033203),
(-1.2735137939453125, 0.20000000298023224, -44.882408142089844),
(-172.87351989746094, 0.20000000298023224, -131.08241271972656)
],
shown in this image:
the path is not completely on the NavMesh. I do not know why?
from recast-navigation-js.
Hey @6ther, could you could share a codesandbox (or similar) reproduction? I'm having some trouble recreating your environment so I can debug.
Using the obj model, the navmesh config provided, and the given start and end points, I get a different result:
from recast-navigation-js.
My code like this:
`
import { init } from "recast-navigation";
import { generateSoloNavMesh } from "recast-navigation/generators";
import { NavMeshQuery } from 'recast-navigation';
import { Crowd } from 'recast-navigation';
export async function getNavMesh()
{
await init();
const positions = [
-173.07352, 0, -131.28241,
-173.07352, 0, 50.717583,
88.92649, 0, 50.717583,
88.92649, 0, -84.2824,
45.926494, 0, -84.2824,
45.926494, 0, -9.2824164,
-83.07351, 0, -9.2824164,
-83.07351, 0, -131.28241,
-173.07352, 0, -131.28241,
];
const indices = [
8, 1, 2,
3, 4, 5,
7, 8, 2,
3, 5, 6,
6, 7, 2,
2, 3, 6
];
const navMeshConfig = {
borderSize:0,
ch:0.2,
cs:0.2,
detailSampleDist:6,
detailSampleMaxError:1,
maxEdgeLen:12,
maxSimplicationError:1.3,
maxVertsPerPoly:6,
mergeRegionArea:20,
minRegionArea:8,
titleSize:0,
walkableClimb:2,
walkableHeight:2,
walkableRedius: 1,
walkableSlopeAngle:60
};
const { success, navMesh } = generateSoloNavMesh(
positions,
indices,
navMeshConfig
);
const navMeshQuery = new NavMeshQuery({ navMesh });
const path = navMeshQuery.computePath(
navMeshQuery.getClosestPoint({ x: 88.92649, y: 0, z: -84.2824}), // start position
navMeshQuery.getClosestPoint({ x: -173.07352, y: 0, z: -131.28241 }) // end position
);
const stringArray: string[] = [];
path.forEach(p => stringArray.push(`(${p.x}, ${p.y}, ${p.z})`))
console.log(stringArray);
}
`
from recast-navigation-js.
Hi @6ther,
I think this is an input issue. There is some difference between the obj model and the positions and indices in the code snippets.
You can visualise the resulting navmesh generated by the above snippet using NavMeshHelper
from recast-navigation/three
:
Creating a buffer geometry shows a geometry that matches the navmesh:
from recast-navigation-js.
Related Issues (20)
- Create examples that don't use react
- Cannot read properties of undefined (reading 'RecastBuildContextImpl') HOT 4
- Add options to high level generators for excluding areas from the navmesh
- Investigate performance opportunities for copying data into Array wrappers HOT 2
- Obstacle queue not processing batches of updates HOT 11
- Fix generateTileCache / threeToTileCache typescript types to omit unsupported RecastConfig options HOT 3
- Expose decodePolyId and encodePolyId HOT 3
- Release 1.0.0
- Exporting with tileCache seems to be working but causes an error when importing HOT 3
- Allow setting the maxStraightPathPolys parameter in computePath HOT 2
- Expose NavMeshQuery `findPolysAroundShape`
- Expose NavMeshQuery `findPath` and `findStraightPath` HOT 1
- Expose NavMeshQuery `findRandomPoint` HOT 1
- Give some control over NavMeshQuery random implementation HOT 1
- Crowd and CrowdAgent improvements
- Add Crowd methods for fixed steps, fixed time stepping with interpolation HOT 2
- Improve performance of DebugDrawer
- Add an example demonstrating how to generate a navmesh in a web worker HOT 1
- Consider removing cjs build HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recast-navigation-js.