Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RecastJSPlugin

RecastJS navigation plugin

Hierarchy

  • RecastJSPlugin

Implements

Index

Constructors

constructor

  • Initializes the recastJS plugin

    Parameters

    • Optional recastInjection: any

      can be used to inject your own recast reference

    Returns RecastJSPlugin

Properties

bjsRECASTSearch playground for bjsRECAST

bjsRECAST: any

Reference to the Recast library

nameSearch playground for name

name: string

plugin name

navMeshSearch playground for navMesh

navMesh: any

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

Methods

addBoxObstacleSearch playground for addBoxObstacle

  • 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

addCylinderObstacleSearch playground for addCylinderObstacle

  • 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

buildFromNavmeshDataSearch playground for buildFromNavmeshData

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

    Parameters

    • data: Uint8Array

      the Uint8Array returned by getNavmeshData

    Returns void

computePathSearch playground for computePath

  • 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

createCrowdSearch playground for createCrowd

  • 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

createDebugNavMeshSearch playground for createDebugNavMesh

createNavMeshSearch playground for createNavMesh

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

    Parameters

    • meshes: Array<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

disposeSearch playground for dispose

  • dispose(): void

getClosestPointSearch playground for getClosestPoint

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

    Parameters

    Returns Vector3

    the closest point to position constrained by the navigation mesh

getClosestPointToRefSearch playground for getClosestPointToRef

  • 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

getDefaultQueryExtentSearch playground for getDefaultQueryExtent

getDefaultQueryExtentToRefSearch playground for getDefaultQueryExtentToRef

  • getDefaultQueryExtentToRef(result: Vector3): void

getMaximumSubStepCountSearch playground for getMaximumSubStepCount

  • getMaximumSubStepCount(): number

getNavmeshDataSearch playground for getNavmeshData

  • 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

getRandomPointAroundSearch playground for getRandomPointAround

  • 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

getRandomPointAroundToRefSearch playground for getRandomPointAroundToRef

  • 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

getTimeStepSearch playground for getTimeStep

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

    Returns number

    the current time step

isSupportedSearch playground for isSupported

  • isSupported(): boolean
  • If this plugin is supported

    Returns boolean

    true if plugin is supported

moveAlongSearch playground for moveAlong

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

    Parameters

    • position: Vector3

      world position

    • destination: Vector3

      world position

    Returns Vector3

    the resulting point along the navmesh

moveAlongToRefSearch playground for moveAlongToRef

  • 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

removeObstacleSearch playground for removeObstacle

  • Removes an obstacle created by addCylinderObstacle or addBoxObstacle

    Parameters

    • obstacle: IObstacle

      obstacle to remove from the navigation

    Returns void

setDefaultQueryExtentSearch playground for setDefaultQueryExtent

  • 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

setMaximumSubStepCountSearch playground for setMaximumSubStepCount

  • 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

setTimeStepSearch playground for setTimeStep

  • 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

setWorkerURLSearch playground for setWorkerURL

  • 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 property
  • Inherited method
  • Static property
  • Static method