You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time a Cube is added, I would like to generate a navmesh from all the top faces (with normals pointing along the up axis) for agents to navigate. Assume there will only be a few dozen cubes on average, or 100 max, so it's practical to just loop through them every time one is added. Cubes are just boxGeometry.
Forgive me if this should be obvious, but is this possible? In all the examples I'm seeing, people are loading in a NavMesh from a .glb, but I'm trying to design agents to move over a landscape that the user will build out. My best attempt so far:
const face1 = new YUKA.Polygon()
const face2 = new YUKA.Polygon()
const faces = []
cubes.forEach((cube) => {
const [x, y, z] = cube
const halfSize = CUBE_SIZE / 2
// Top face of the cube
const v1 = new YUKA.Vector3(x - halfSize, y + halfSize, z - halfSize)
const v2 = new YUKA.Vector3(x + halfSize, y + halfSize, z - halfSize)
const v3 = new YUKA.Vector3(x + halfSize, y + halfSize, z + halfSize)
const v4 = new YUKA.Vector3(x - halfSize, y + halfSize, z + halfSize)
console.log("v1", v1)
console.log("v2", v2)
console.log("v3", v3)
console.log("v4", v4)
face1.fromContour([v1, v2, v3])
face2.fromContour([v1, v3, v4])
faces.push(face1)
faces.push(face2)
})
let newNavMesh = new YUKA.NavMesh()
newNavMesh.fromPolygons(faces)
navMesh = newNavMesh
The text was updated successfully, but these errors were encountered:
Consider this example of a Minecraft-like experience:
https://github.com/pmndrs/xr/tree/main/examples/minecraft
Every time a Cube is added, I would like to generate a navmesh from all the top faces (with normals pointing along the up axis) for agents to navigate. Assume there will only be a few dozen cubes on average, or 100 max, so it's practical to just loop through them every time one is added. Cubes are just boxGeometry.
Forgive me if this should be obvious, but is this possible? In all the examples I'm seeing, people are loading in a NavMesh from a .glb, but I'm trying to design agents to move over a landscape that the user will build out. My best attempt so far:
The text was updated successfully, but these errors were encountered: