Code Monkey home page Code Monkey logo

Comments (5)

isaac-mason avatar isaac-mason commented on May 29, 2024

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:

image

Let me know if I'm doing something silly.

from recast-navigation-js.

6ther avatar 6ther commented on May 29, 2024

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:
image
the path is not completely on the NavMesh. I do not know why?

from recast-navigation-js.

isaac-mason avatar isaac-mason commented on May 29, 2024

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:

image

from recast-navigation-js.

6ther avatar 6ther commented on May 29, 2024

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.

isaac-mason avatar isaac-mason commented on May 29, 2024

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:

image

Creating a buffer geometry shows a geometry that matches the navmesh:

image

from recast-navigation-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.