Options
All
  • Public
  • Public/Protected
  • All
Menu

RecastJS navigation plugin

Hierarchy

  • RecastJSPlugin

Implements

Index

Constructors

  • Initializes the recastJS plugin

    Parameters

    • Optional recastInjection: any

      can be used to inject your own recast reference

    Returns RecastJSPlugin

Properties

bjsRECAST: any

Reference to the Recast library

name: string

plugin name

navMesh: any

the first navmesh created. We might extend this to support multiple navmeshes

Methods

  • Creates an oriented box obstacle and add it to the navigation

    Parameters

    • position: Vector3

      world position

    • extent: Vector3

      box size

    • angle: number

      angle in radians of the box orientation on Y axis

    Returns IObstacle

    the obstacle freshly created

  • addCylinderObstacle(position: Vector3, radius: number, height: number): IObstacle
  • Creates a cylinder obstacle and add it to the navigation

    Parameters

    • position: Vector3

      world position

    • radius: number

      cylinder radius

    • height: number

      cylinder height

    Returns IObstacle

    the obstacle freshly created

  • buildFromNavmeshData(data: Uint8Array): void
  • build the navmesh from a previously saved state using getNavmeshData

    Parameters

    • data: Uint8Array

      the Uint8Array returned by getNavmeshData

    Returns void

  • Compute a navigation path from start to end. Returns an empty array if no path can be computed

    Parameters

    Returns Vector3[]

    array containing world position composing the path

  • createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd
  • Create a new Crowd so you can add agents

    Parameters

    • maxAgents: number

      the maximum agent count in the crowd

    • maxAgentRadius: number

      the maximum radius an agent can have

    • scene: Scene

      to attach the crowd to

    Returns ICrowd

    the crowd you can add agents to

  • createNavMesh(meshes: Mesh[], parameters: INavMeshParameters, completion?: (navmeshData: Uint8Array) => void): void
  • Creates a navigation mesh

    Parameters

    • meshes: Mesh[]

      array of all the geometry used to compute the navigation mesh

    • parameters: INavMeshParameters

      bunch of parameters used to filter geometry

    • Optional completion: (navmeshData: Uint8Array) => void

      callback when data is available from the worker. Not used without a worker

        • (navmeshData: Uint8Array): void
        • Parameters

          • navmeshData: Uint8Array

          Returns void

    Returns void

  • dispose(): void
  • Get a navigation mesh constrained position, closest to the parameter position

    Parameters

    Returns Vector3

    the closest point to position constrained by the navigation mesh

  • Get a navigation mesh constrained position, closest to the parameter position

    Parameters

    • position: Vector3

      world position

    • result: Vector3

      output the closest point to position constrained by the navigation mesh

    Returns void

  • getDefaultQueryExtentToRef(result: Vector3): void
  • getMaximumSubStepCount(): number
  • getNavmeshData(): Uint8Array
  • returns the navmesh data that can be used later. The navmesh must be built before retrieving the data

    Returns Uint8Array

    data the Uint8Array that can be saved and reused

  • Get a navigation mesh constrained position, within a particular radius

    Parameters

    • position: Vector3

      world position

    • maxRadius: number

      the maximum distance to the constrained world position

    Returns Vector3

    the closest point to position constrained by the navigation mesh

  • getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void
  • Get a navigation mesh constrained position, within a particular radius

    Parameters

    • position: Vector3

      world position

    • maxRadius: number

      the maximum distance to the constrained world position

    • result: Vector3

      output the closest point to position constrained by the navigation mesh

    Returns void

  • getTimeStep(): number
  • Get the time step of the navigation tick update.

    Returns number

    the current time step

  • isSupported(): boolean
  • Compute the final position from a segment made of destination-position

    Parameters

    Returns Vector3

    the resulting point along the navmesh

  • Compute the final position from a segment made of destination-position

    Parameters

    • position: Vector3

      world position

    • destination: Vector3

      world position

    • result: Vector3

      output the resulting point along the navmesh

    Returns void

  • Removes an obstacle created by addCylinderObstacle or addBoxObstacle

    Parameters

    • obstacle: IObstacle

      obstacle to remove from the navigation

    Returns void

  • setDefaultQueryExtent(extent: Vector3): void
  • Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...) The queries will try to find a solution within those bounds default is (1,1,1)

    Parameters

    • extent: Vector3

      x,y,z value that define the extent around the queries point of reference

    Returns void

  • setMaximumSubStepCount(newStepCount?: number): void
  • If delta time in navigation tick update is greater than the time step a number of sub iterations are done. If more iterations are need to reach deltatime they will be discarded. A value of 0 will set to no maximum and update will use as many substeps as needed

    Parameters

    • Optional newStepCount: number

      the maximum number of iterations

    Returns void

  • setTimeStep(newTimeStep?: number): void
  • Set the time step of the navigation tick update. Default is 1/60. A value of 0 will disable fixed time update

    Parameters

    • Optional newTimeStep: number

      the new timestep to apply to this world.

    Returns void

  • setWorkerURL(workerURL: string): boolean
  • Set worker URL to be used when generating a new navmesh

    Parameters

    • workerURL: string

      url string

    Returns boolean

    boolean indicating if worker is created

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited constructor
  • Static method

Settings

Theme