@onerjs/addons 8.42.6 → 8.42.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/atmosphere/atmosphere.d.ts +6 -0
- package/atmosphere/atmosphere.js +42 -0
- package/atmosphere/atmosphere.js.map +1 -1
- package/atmosphere/atmospherePBRMaterialPlugin.js +15 -5
- package/atmosphere/atmospherePBRMaterialPlugin.js.map +1 -1
- package/msdfText/textRenderer.js +2 -2
- package/msdfText/textRenderer.js.map +1 -1
- package/navigation/common/config.d.ts +5 -5
- package/navigation/common/config.js +5 -5
- package/navigation/common/config.js.map +1 -1
- package/navigation/common/smooth-path.js +1 -1
- package/navigation/common/smooth-path.js.map +1 -1
- package/navigation/plugin/RecastJSCrowd.d.ts +2 -2
- package/navigation/plugin/RecastJSCrowd.js.map +1 -1
- package/navigation/plugin/RecastNavigationJSPlugin.d.ts +7 -6
- package/navigation/plugin/RecastNavigationJSPlugin.js +7 -6
- package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -1
- package/navigation/types.d.ts +1 -1
- package/navigation/types.js.map +1 -1
- package/navigation/worker/navmesh-worker.js +1 -1
- package/navigation/worker/navmesh-worker.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecastJSCrowd.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastJSCrowd.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,0CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,6CAAkC;AAEpD,OAAO,EAAE,UAAU,EAAE,wCAA6B;AAKlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACtB;;OAEG;IACH,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,iBAAiB,CAA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AC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,SAAS,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAE5B,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAClF,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { Crowd } from \"@recast-navigation/core\";\n\nimport type { Nullable } from \"core/types\";\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { TransformNode } from \"core/Meshes/transformNode\";\nimport type { ICrowd } from \"core/Navigation/INavigationEngine\";\nimport { Vector3 } from \"core/Maths/math.vector\";\nimport { Epsilon } from \"core/Maths/math.constants\";\nimport type { Observer } from \"core/Misc/observable\";\nimport { Observable } from \"core/Misc/observable\";\nimport type { Scene } from \"core/scene\";\n\nimport type { RecastNavigationJSPluginV2 } from \"./RecastNavigationJSPlugin\";\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { ToCrowdAgentParams } from \"../common/config\";\nimport type { IAgentParametersV2 } from \"../types\";\nimport { GetRecast } from \"../factory/common\";\n\n/**\n * Recast Detour crowd implementation\n * This class provides methods to manage a crowd of agents, allowing them to navigate a navigation mesh.\n * It supports adding agents, updating their parameters, moving them to destinations, and checking their states.\n * The crowd is updated in the scene's animation loop, and it notifies observers when agents reach their destinations.\n */\nexport class RecastJSCrowd implements ICrowd {\n /**\n * Recast plugin\n */\n public get navigationPlugin(): RecastNavigationJSPluginV2 {\n return this._navigationPlugin;\n }\n\n /**\n * Link to the detour crowd\n */\n public get recastCrowd(): Crowd {\n return this._recastCrowd;\n }\n\n /**\n * One transform per agent\n */\n public get transforms(): TransformNode[] {\n return this._transforms;\n }\n\n /**\n * All agents created\n */\n public get agents(): readonly number[] {\n return Object.freeze(this._agents);\n }\n\n /**\n * Agents reach radius\n */\n public get reachRadii(): readonly number[] {\n return Object.freeze(this._reachRadii);\n }\n\n private _navigationPlugin: RecastNavigationJSPluginV2;\n private _recastCrowd: Crowd;\n private _transforms: TransformNode[] = [];\n private _agents: number[] = [];\n private _reachRadii: number[] = [];\n\n /**\n * true when a destination is active for an agent and notifier hasn't been notified of reach\n */\n private _agentDestinationArmed: boolean[] = new Array<boolean>();\n /**\n * agent current target\n */\n private _agentDestination: Vector3[] = new Array<Vector3>();\n /**\n * Link to the scene is kept to unregister the crowd from the scene\n */\n private _scene: Scene;\n\n private _engine: AbstractEngine;\n\n /**\n * Observer for crowd updates\n */\n private _onBeforeAnimationsObserver: Nullable<Observer<Scene>> = null;\n\n /**\n * Fires each time an agent is in reach radius of its destination\n */\n public onReachTargetObservable = new Observable<{\n /**\n *\n */\n agentIndex: number;\n /**\n *\n */\n destination: Vector3;\n }>();\n\n /**\n * Constructor\n * @param plugin recastJS plugin\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public constructor(plugin: RecastNavigationJSPluginV2, maxAgents: number, maxAgentRadius: number, scene: Scene) {\n this._navigationPlugin = plugin;\n\n if (!plugin.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n\n this._recastCrowd = new (GetRecast().Crowd)(plugin.navMesh, {\n maxAgents,\n maxAgentRadius,\n });\n\n this._scene = scene;\n this._engine = scene.getEngine();\n\n this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\n this.update(this._engine.getDeltaTime() * 0.001 * plugin.timeFactor);\n });\n }\n\n /**\n * Add a new agent to the crowd with the specified parameter a corresponding transformNode.\n * You can attach anything to that node. The node position is updated in the scene update tick.\n * @param pos world position that will be constrained by the navigation mesh\n * @param parameters agent parameters\n * @param transform hooked to the agent that will be update by the scene\n * @returns agent index\n */\n public addAgent(pos: IVector3Like, parameters: IAgentParametersV2, transform: TransformNode): number {\n const agentParams = ToCrowdAgentParams(parameters);\n\n const agent = this._recastCrowd.addAgent({ x: pos.x, y: pos.y, z: pos.z }, agentParams);\n\n this._transforms.push(transform);\n this._agents.push(agent.agentIndex);\n this._reachRadii.push(parameters.reachRadius ? parameters.reachRadius : parameters.radius);\n this._agentDestinationArmed.push(false);\n this._agentDestination.push(new Vector3(0, 0, 0));\n\n return agent.agentIndex;\n }\n\n /**\n * Returns the agent position in world space\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentPosition(index: number): Vector3 {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent position result in world space\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentPositionToRef(index: number, result: Vector3): void {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n result.set(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent velocity in world space\n * @param index agent index returned by addAgent\n * @returns world space velocity\n */\n public getAgentVelocity(index: number): Vector3 {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent velocity result in world space\n * @param index agent index returned by addAgent\n * @param result output world space velocity\n */\n public getAgentVelocityToRef(index: number, result: Vector3): void {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n result.set(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentNextTargetPath(index: number): Vector3 {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n return new Vector3(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentNextTargetPathToRef(index: number, result: Vector3): void {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n result.set(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Gets the agent state\n * @param index agent index returned by addAgent\n * @returns agent state, 0 = DT_CROWDAGENT_STATE_INVALID, 1 = DT_CROWDAGENT_STATE_WALKING, 2 = DT_CROWDAGENT_STATE_OFFMESH\n */\n public getAgentState(index: number): number {\n return this._recastCrowd.getAgent(index)?.state() ?? 0; // invalid\n }\n\n /**\n * returns true if the agent in over an off mesh link connection\n * @param index agent index returned by addAgent\n * @returns true if over an off mesh link connection\n */\n public overOffmeshConnection(index: number): boolean {\n return this._recastCrowd.getAgent(index)?.overOffMeshConnection() ?? false;\n }\n\n /**\n * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentGoto(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.requestMoveTarget(destination);\n\n // arm observer\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agentDestinationArmed[item] = true;\n this._agentDestination[item].set(destination.x, destination.y, destination.z);\n }\n }\n\n /**\n * Teleport the agent to a new position\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentTeleport(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.teleport(destination);\n }\n\n /**\n * Update agent parameters\n * @param index agent index returned by addAgent\n * @param parameters agent parameters\n */\n public updateAgentParameters(index: number, parameters: IAgentParametersV2): void {\n const agent = this._recastCrowd.getAgent(index);\n if (!agent) {\n return;\n }\n\n const agentParams = agent.parameters();\n\n if (!agentParams) {\n return;\n }\n\n if (parameters.radius !== undefined) {\n agentParams.radius = parameters.radius;\n }\n if (parameters.height !== undefined) {\n agentParams.height = parameters.height;\n }\n if (parameters.maxAcceleration !== undefined) {\n agentParams.maxAcceleration = parameters.maxAcceleration;\n }\n if (parameters.maxSpeed !== undefined) {\n agentParams.maxSpeed = parameters.maxSpeed;\n }\n if (parameters.collisionQueryRange !== undefined) {\n agentParams.collisionQueryRange = parameters.collisionQueryRange;\n }\n if (parameters.pathOptimizationRange !== undefined) {\n agentParams.pathOptimizationRange = parameters.pathOptimizationRange;\n }\n if (parameters.separationWeight !== undefined) {\n agentParams.separationWeight = parameters.separationWeight;\n }\n\n agent.updateParameters(agentParams);\n }\n\n /**\n * remove a particular agent previously created\n * @param index agent index returned by addAgent\n */\n public removeAgent(index: number): void {\n this._recastCrowd.removeAgent(index);\n\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agents.splice(item, 1);\n this._transforms.splice(item, 1);\n this._reachRadii.splice(item, 1);\n this._agentDestinationArmed.splice(item, 1);\n this._agentDestination.splice(item, 1);\n }\n }\n\n /**\n * get the list of all agents attached to this crowd\n * @returns list of agent indices\n */\n public getAgents(): number[] {\n return this._agents;\n }\n\n /**\n * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function\n * @param deltaTime in seconds\n */\n public update(deltaTime: number): void {\n if (deltaTime <= Epsilon) {\n return;\n }\n\n // update crowd\n const timeStep = this._navigationPlugin.getTimeStep();\n const maxStepCount = this._navigationPlugin.getMaximumSubStepCount();\n if (timeStep <= Epsilon) {\n this._recastCrowd.update(deltaTime);\n } else {\n let iterationCount = Math.floor(deltaTime / timeStep);\n if (maxStepCount && iterationCount > maxStepCount) {\n iterationCount = maxStepCount;\n }\n if (iterationCount < 1) {\n iterationCount = 1;\n }\n\n const step = deltaTime / iterationCount;\n for (let i = 0; i < iterationCount; i++) {\n this._recastCrowd.update(step);\n }\n }\n\n // update transforms\n for (let index = 0; index < this._agents.length; index++) {\n // update transform position\n const agentIndex = this._agents[index];\n const agentPosition = this.getAgentPosition(agentIndex);\n this._transforms[index].position = agentPosition;\n // check agent reach destination\n if (this._agentDestinationArmed[index]) {\n const dx = agentPosition.x - this._agentDestination[index].x;\n const dz = agentPosition.z - this._agentDestination[index].z;\n const radius = this._reachRadii[index];\n const groundY = this._agentDestination[index].y - this._reachRadii[index];\n const ceilingY = this._agentDestination[index].y + this._reachRadii[index];\n const distanceXZSquared = dx * dx + dz * dz;\n if (agentPosition.y > groundY && agentPosition.y < ceilingY && distanceXZSquared < radius * radius) {\n this._agentDestinationArmed[index] = false;\n this.onReachTargetObservable.notifyObservers({\n agentIndex: agentIndex,\n destination: this._agentDestination[index],\n });\n }\n }\n }\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n setDefaultQueryExtent(extent: IVector3Like): void {\n this._navigationPlugin.setDefaultQueryExtent(extent);\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n getDefaultQueryExtent(): Vector3 {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n return new Vector3(p.x, p.y, p.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n getDefaultQueryExtentToRef(result: Vector3): void {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n result.set(p.x, p.y, p.z);\n }\n\n /**\n * Get the next corner points composing the path (max 4 points)\n * @param index agent index returned by addAgent\n * @returns array containing world position composing the path\n */\n public getCorners(index: number): Vector3[] {\n const corners = this._recastCrowd.getAgent(index)?.corners();\n if (!corners) {\n return [];\n }\n\n const positions = [];\n for (let i = 0; i < corners.length; i++) {\n positions.push(new Vector3(corners[i].x, corners[i].y, corners[i].z));\n }\n return positions;\n }\n\n /**\n * Release all resources\n */\n public dispose(): void {\n this._recastCrowd.destroy();\n\n if (this._onBeforeAnimationsObserver) {\n this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);\n this._onBeforeAnimationsObserver = null;\n }\n\n this.onReachTargetObservable.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RecastJSCrowd.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastJSCrowd.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,0CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,6CAAkC;AAEpD,OAAO,EAAE,UAAU,EAAE,wCAA6B;AAKlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACtB;;OAEG;IACH,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,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C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAE5B,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,4BAA4B,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAClF,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import type { Crowd } from \"@recast-navigation/core\";\n\nimport type { Nullable } from \"core/types\";\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { TransformNode } from \"core/Meshes/transformNode\";\nimport type { ICrowd } from \"core/Navigation/INavigationEngine\";\nimport { Vector3 } from \"core/Maths/math.vector\";\nimport { Epsilon } from \"core/Maths/math.constants\";\nimport type { Observer } from \"core/Misc/observable\";\nimport { Observable } from \"core/Misc/observable\";\nimport type { Scene } from \"core/scene\";\n\nimport type { RecastNavigationJSPluginV2 } from \"./RecastNavigationJSPlugin\";\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { ToCrowdAgentParams } from \"../common/config\";\nimport type { IAgentParametersV2 } from \"../types\";\nimport { GetRecast } from \"../factory/common\";\n\n/**\n * Recast Detour crowd implementation\n * This class provides methods to manage a crowd of agents, allowing them to navigate a navigation mesh.\n * It supports adding agents, updating their parameters, moving them to destinations, and checking their states.\n * The crowd is updated in the scene's animation loop, and it notifies observers when agents reach their destinations.\n */\nexport class RecastJSCrowd implements ICrowd {\n /**\n * Recast plugin\n */\n public get navigationPlugin(): RecastNavigationJSPluginV2 {\n return this._navigationPlugin;\n }\n\n /**\n * Link to the detour crowd\n */\n public get recastCrowd(): Crowd {\n return this._recastCrowd;\n }\n\n /**\n * One transform per agent\n */\n public get transforms(): TransformNode[] {\n return this._transforms;\n }\n\n /**\n * All agents created\n */\n public get agents(): readonly number[] {\n return Object.freeze(this._agents);\n }\n\n /**\n * Agents reach radius\n */\n public get reachRadii(): readonly number[] {\n return Object.freeze(this._reachRadii);\n }\n\n private _navigationPlugin: RecastNavigationJSPluginV2;\n private _recastCrowd: Crowd;\n private _transforms: TransformNode[] = [];\n private _agents: number[] = [];\n private _reachRadii: number[] = [];\n\n /**\n * true when a destination is active for an agent and notifier hasn't been notified of reach\n */\n private _agentDestinationArmed: boolean[] = new Array<boolean>();\n /**\n * agent current target\n */\n private _agentDestination: Vector3[] = new Array<Vector3>();\n /**\n * Link to the scene is kept to unregister the crowd from the scene\n */\n private _scene: Scene;\n\n private _engine: AbstractEngine;\n\n /**\n * Observer for crowd updates\n */\n private _onBeforeAnimationsObserver: Nullable<Observer<Scene>> = null;\n\n /**\n * Fires each time an agent is in reach radius of its destination\n */\n public onReachTargetObservable = new Observable<{\n /**\n * The index of the agent that reached its target\n */\n agentIndex: number;\n /**\n * The destination that the agent reached\n */\n destination: Vector3;\n }>();\n\n /**\n * Constructor\n * @param plugin recastJS plugin\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public constructor(plugin: RecastNavigationJSPluginV2, maxAgents: number, maxAgentRadius: number, scene: Scene) {\n this._navigationPlugin = plugin;\n\n if (!plugin.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n\n this._recastCrowd = new (GetRecast().Crowd)(plugin.navMesh, {\n maxAgents,\n maxAgentRadius,\n });\n\n this._scene = scene;\n this._engine = scene.getEngine();\n\n this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\n this.update(this._engine.getDeltaTime() * 0.001 * plugin.timeFactor);\n });\n }\n\n /**\n * Add a new agent to the crowd with the specified parameter a corresponding transformNode.\n * You can attach anything to that node. The node position is updated in the scene update tick.\n * @param pos world position that will be constrained by the navigation mesh\n * @param parameters agent parameters\n * @param transform hooked to the agent that will be update by the scene\n * @returns agent index\n */\n public addAgent(pos: IVector3Like, parameters: IAgentParametersV2, transform: TransformNode): number {\n const agentParams = ToCrowdAgentParams(parameters);\n\n const agent = this._recastCrowd.addAgent({ x: pos.x, y: pos.y, z: pos.z }, agentParams);\n\n this._transforms.push(transform);\n this._agents.push(agent.agentIndex);\n this._reachRadii.push(parameters.reachRadius ? parameters.reachRadius : parameters.radius);\n this._agentDestinationArmed.push(false);\n this._agentDestination.push(new Vector3(0, 0, 0));\n\n return agent.agentIndex;\n }\n\n /**\n * Returns the agent position in world space\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentPosition(index: number): Vector3 {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent position result in world space\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentPositionToRef(index: number, result: Vector3): void {\n const agentPos = this._recastCrowd.getAgent(index)?.position() ?? Vector3.ZeroReadOnly;\n result.set(agentPos.x, agentPos.y, agentPos.z);\n }\n\n /**\n * Returns the agent velocity in world space\n * @param index agent index returned by addAgent\n * @returns world space velocity\n */\n public getAgentVelocity(index: number): Vector3 {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n return new Vector3(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent velocity result in world space\n * @param index agent index returned by addAgent\n * @param result output world space velocity\n */\n public getAgentVelocityToRef(index: number, result: Vector3): void {\n const agentVel = this._recastCrowd.getAgent(index)?.velocity() ?? Vector3.ZeroReadOnly;\n result.set(agentVel.x, agentVel.y, agentVel.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @returns world space position\n */\n public getAgentNextTargetPath(index: number): Vector3 {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n return new Vector3(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Returns the agent next target point on the path\n * @param index agent index returned by addAgent\n * @param result output world space position\n */\n public getAgentNextTargetPathToRef(index: number, result: Vector3): void {\n const pathTargetPos = this._recastCrowd.getAgent(index)?.nextTargetInPath() ?? Vector3.ZeroReadOnly;\n result.set(pathTargetPos.x, pathTargetPos.y, pathTargetPos.z);\n }\n\n /**\n * Gets the agent state\n * @param index agent index returned by addAgent\n * @returns agent state, 0 = DT_CROWDAGENT_STATE_INVALID, 1 = DT_CROWDAGENT_STATE_WALKING, 2 = DT_CROWDAGENT_STATE_OFFMESH\n */\n public getAgentState(index: number): number {\n return this._recastCrowd.getAgent(index)?.state() ?? 0; // invalid\n }\n\n /**\n * returns true if the agent in over an off mesh link connection\n * @param index agent index returned by addAgent\n * @returns true if over an off mesh link connection\n */\n public overOffmeshConnection(index: number): boolean {\n return this._recastCrowd.getAgent(index)?.overOffMeshConnection() ?? false;\n }\n\n /**\n * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentGoto(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.requestMoveTarget(destination);\n\n // arm observer\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agentDestinationArmed[item] = true;\n this._agentDestination[item].set(destination.x, destination.y, destination.z);\n }\n }\n\n /**\n * Teleport the agent to a new position\n * @param index agent index returned by addAgent\n * @param destination targeted world position\n */\n public agentTeleport(index: number, destination: IVector3Like): void {\n this._recastCrowd.getAgent(index)?.teleport(destination);\n }\n\n /**\n * Update agent parameters\n * @param index agent index returned by addAgent\n * @param parameters agent parameters\n */\n public updateAgentParameters(index: number, parameters: IAgentParametersV2): void {\n const agent = this._recastCrowd.getAgent(index);\n if (!agent) {\n return;\n }\n\n const agentParams = agent.parameters();\n\n if (!agentParams) {\n return;\n }\n\n if (parameters.radius !== undefined) {\n agentParams.radius = parameters.radius;\n }\n if (parameters.height !== undefined) {\n agentParams.height = parameters.height;\n }\n if (parameters.maxAcceleration !== undefined) {\n agentParams.maxAcceleration = parameters.maxAcceleration;\n }\n if (parameters.maxSpeed !== undefined) {\n agentParams.maxSpeed = parameters.maxSpeed;\n }\n if (parameters.collisionQueryRange !== undefined) {\n agentParams.collisionQueryRange = parameters.collisionQueryRange;\n }\n if (parameters.pathOptimizationRange !== undefined) {\n agentParams.pathOptimizationRange = parameters.pathOptimizationRange;\n }\n if (parameters.separationWeight !== undefined) {\n agentParams.separationWeight = parameters.separationWeight;\n }\n\n agent.updateParameters(agentParams);\n }\n\n /**\n * remove a particular agent previously created\n * @param index agent index returned by addAgent\n */\n public removeAgent(index: number): void {\n this._recastCrowd.removeAgent(index);\n\n const item = this._agents.indexOf(index);\n if (item > -1) {\n this._agents.splice(item, 1);\n this._transforms.splice(item, 1);\n this._reachRadii.splice(item, 1);\n this._agentDestinationArmed.splice(item, 1);\n this._agentDestination.splice(item, 1);\n }\n }\n\n /**\n * get the list of all agents attached to this crowd\n * @returns list of agent indices\n */\n public getAgents(): number[] {\n return this._agents;\n }\n\n /**\n * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function\n * @param deltaTime in seconds\n */\n public update(deltaTime: number): void {\n if (deltaTime <= Epsilon) {\n return;\n }\n\n // update crowd\n const timeStep = this._navigationPlugin.getTimeStep();\n const maxStepCount = this._navigationPlugin.getMaximumSubStepCount();\n if (timeStep <= Epsilon) {\n this._recastCrowd.update(deltaTime);\n } else {\n let iterationCount = Math.floor(deltaTime / timeStep);\n if (maxStepCount && iterationCount > maxStepCount) {\n iterationCount = maxStepCount;\n }\n if (iterationCount < 1) {\n iterationCount = 1;\n }\n\n const step = deltaTime / iterationCount;\n for (let i = 0; i < iterationCount; i++) {\n this._recastCrowd.update(step);\n }\n }\n\n // update transforms\n for (let index = 0; index < this._agents.length; index++) {\n // update transform position\n const agentIndex = this._agents[index];\n const agentPosition = this.getAgentPosition(agentIndex);\n this._transforms[index].position = agentPosition;\n // check agent reach destination\n if (this._agentDestinationArmed[index]) {\n const dx = agentPosition.x - this._agentDestination[index].x;\n const dz = agentPosition.z - this._agentDestination[index].z;\n const radius = this._reachRadii[index];\n const groundY = this._agentDestination[index].y - this._reachRadii[index];\n const ceilingY = this._agentDestination[index].y + this._reachRadii[index];\n const distanceXZSquared = dx * dx + dz * dz;\n if (agentPosition.y > groundY && agentPosition.y < ceilingY && distanceXZSquared < radius * radius) {\n this._agentDestinationArmed[index] = false;\n this.onReachTargetObservable.notifyObservers({\n agentIndex: agentIndex,\n destination: this._agentDestination[index],\n });\n }\n }\n }\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n setDefaultQueryExtent(extent: IVector3Like): void {\n this._navigationPlugin.setDefaultQueryExtent(extent);\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n getDefaultQueryExtent(): Vector3 {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n return new Vector3(p.x, p.y, p.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n getDefaultQueryExtentToRef(result: Vector3): void {\n const p = this._navigationPlugin.getDefaultQueryExtent();\n result.set(p.x, p.y, p.z);\n }\n\n /**\n * Get the next corner points composing the path (max 4 points)\n * @param index agent index returned by addAgent\n * @returns array containing world position composing the path\n */\n public getCorners(index: number): Vector3[] {\n const corners = this._recastCrowd.getAgent(index)?.corners();\n if (!corners) {\n return [];\n }\n\n const positions = [];\n for (let i = 0; i < corners.length; i++) {\n positions.push(new Vector3(corners[i].x, corners[i].y, corners[i].z));\n }\n return positions;\n }\n\n /**\n * Release all resources\n */\n public dispose(): void {\n this._recastCrowd.destroy();\n\n if (this._onBeforeAnimationsObserver) {\n this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);\n this._onBeforeAnimationsObserver = null;\n }\n\n this.onReachTargetObservable.clear();\n }\n}\n"]}
|
|
@@ -50,7 +50,7 @@ export declare class RecastNavigationJSPluginV2 implements INavigationEnginePlug
|
|
|
50
50
|
/**
|
|
51
51
|
* Intermediates generated during the navmesh creation
|
|
52
52
|
* @remarks This is used for debugging and visualization purposes.
|
|
53
|
-
* @remarks You have access to vertices, indices and vertex colors to
|
|
53
|
+
* @remarks You have access to vertices, indices and vertex colors to visualize the navmesh creation process.
|
|
54
54
|
* @remarks This is only available if the `keepIntermediates` parameter is set
|
|
55
55
|
* @remarks to true during navmesh generation.
|
|
56
56
|
*/
|
|
@@ -254,9 +254,10 @@ export declare class RecastNavigationJSPluginV2 implements INavigationEnginePlug
|
|
|
254
254
|
maxStraightPathPoints?: number;
|
|
255
255
|
}): Vector3[];
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* @param
|
|
257
|
+
* Compute a navigation path from start to end. Returns an empty array if no path can be computed.
|
|
258
|
+
* Path follows navigation mesh geometry.
|
|
259
|
+
* @param start world position
|
|
260
|
+
* @param end world position
|
|
260
261
|
* @param options options to configure the path computation
|
|
261
262
|
* @returns array containing world position composing the path
|
|
262
263
|
*/
|
|
@@ -381,9 +382,9 @@ export declare class RecastNavigationJSPluginV2 implements INavigationEnginePlug
|
|
|
381
382
|
};
|
|
382
383
|
/**
|
|
383
384
|
* Compute the final position from a segment made of destination-position, and return the height of the polygon
|
|
384
|
-
* This is a more
|
|
385
|
+
* This is a more sophisticated version of moveAlong that will use the height of the polygon at the end position
|
|
385
386
|
* @param position world position to start from
|
|
386
|
-
* @param velocity
|
|
387
|
+
* @param velocity velocity of the movement
|
|
387
388
|
* @param options options for the function
|
|
388
389
|
* @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon
|
|
389
390
|
*/
|
|
@@ -230,9 +230,10 @@ export class RecastNavigationJSPluginV2 {
|
|
|
230
230
|
return ConvertNavPathPoints(this._navMeshQuery.computePath(start, end, options));
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* @param
|
|
233
|
+
* Compute a navigation path from start to end. Returns an empty array if no path can be computed.
|
|
234
|
+
* Path follows navigation mesh geometry.
|
|
235
|
+
* @param start world position
|
|
236
|
+
* @param end world position
|
|
236
237
|
* @param options options to configure the path computation
|
|
237
238
|
* @returns array containing world position composing the path
|
|
238
239
|
*/
|
|
@@ -398,7 +399,7 @@ export class RecastNavigationJSPluginV2 {
|
|
|
398
399
|
setRandomSeed(seed) {
|
|
399
400
|
this.bjsRECAST.setRandomSeed(seed);
|
|
400
401
|
}
|
|
401
|
-
// New
|
|
402
|
+
// New functions beyond the INavigationEnginePlugin interface
|
|
402
403
|
/**
|
|
403
404
|
* Perform a raycast on the navmesh
|
|
404
405
|
* @param start start position
|
|
@@ -428,9 +429,9 @@ export class RecastNavigationJSPluginV2 {
|
|
|
428
429
|
}
|
|
429
430
|
/**
|
|
430
431
|
* Compute the final position from a segment made of destination-position, and return the height of the polygon
|
|
431
|
-
* This is a more
|
|
432
|
+
* This is a more sophisticated version of moveAlong that will use the height of the polygon at the end position
|
|
432
433
|
* @param position world position to start from
|
|
433
|
-
* @param velocity
|
|
434
|
+
* @param velocity velocity of the movement
|
|
434
435
|
* @param options options for the function
|
|
435
436
|
* @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon
|
|
436
437
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecastNavigationJSPlugin.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,oCAAyB;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C;QAEnC,OAAO;YACH,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,wBAAwB;SACxD,CAAC;IACN,CAAC;IAEO,qBAAqB,CAAC,UAAgC;QAC1D,uGAAuG;QACvG,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACxC,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,wEAAwE;YACzH,UAAU,CAAC,YAAY,GAAG,mBAAmB,CAAC;QAClD,CAAC;QAED,UAAU,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;CACJ","sourcesContent":["import type { TileCacheMeshProcess, NavMesh, QueryFilter, TileCache, NavMeshQuery } from \"@recast-navigation/core\";\n\nimport type { ICrowd, INavigationEnginePlugin, IObstacle } from \"core/Navigation/INavigationEngine\";\nimport { Logger } from \"core/Misc/logger\";\nimport type { Mesh } from \"core/Meshes/mesh\";\nimport type { Scene } from \"core/scene\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math\";\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { Nullable } from \"core/types\";\n\nimport type { CreateNavMeshResult, GeneratorIntermediates, INavMeshParametersV2, RecastInjection } from \"../types\";\nimport { RecastJSCrowd } from \"./RecastJSCrowd\";\nimport { ConvertNavPathPoints } from \"../common/convert\";\nimport { ComputeSmoothPath } from \"../common/smooth-path\";\nimport { CreateDebugNavMesh } from \"../debug/simple-debug\";\nimport { GetRecast } from \"../factory/common\";\nimport { InjectGenerators } from \"../generator/injection\";\nimport { DefaultMaxObstacles } from \"../common/config\";\nimport { CreateDefaultTileCacheMeshProcess, WaitForFullTileCacheUpdate } from \"../common/tile-cache\";\n\n/**\n * Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.\n * @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library\n * @remarks It supports both single-threaded and multi-threaded generation of navigation meshes.\n * @remarks The plugin can be used to create navigation meshes from meshes in a scene, compute paths, and manage crowd agents, etc.\n * @remarks It also provides methods for creating obstacles and querying the navigation mesh.\n * @see https://github.com/isaac-mason/recast-navigation-js\n */\nexport class RecastNavigationJSPluginV2 implements INavigationEnginePlugin {\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => CreateNavMeshResult;\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshAsyncImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => Promise<CreateNavMeshResult>;\n\n /**\n * recast-navigation-js injection\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public bjsRECAST: RecastInjection;\n\n /**\n * plugin name\n */\n public name: string = \"RecastNavigationJSPlugin\";\n\n /**\n * the navmesh created\n */\n public navMesh?: NavMesh;\n\n /**\n * The navmesh query created from the navmesh\n * @remarks This is used to query the navmesh for pathfinding and other navigation tasks\n */\n public get navMeshQuery(): NavMeshQuery {\n return this._navMeshQuery;\n }\n\n private _navMeshQuery!: NavMeshQuery;\n\n /**\n * Intermediates generated during the navmesh creation\n * @remarks This is used for debugging and visualization purposes.\n * @remarks You have access to vertices, indices and vertex colors to visusalize the navmesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set\n * @remarks to true during navmesh generation.\n */\n private _intermediates?: GeneratorIntermediates;\n\n /**\n * Gets the intermediates generated during the navmesh creation\n * @returns The generator intermediates, or undefined if not available\n */\n public get intermediates(): GeneratorIntermediates | undefined {\n return this._intermediates;\n }\n\n /**\n * Tile cache used for tiled navigation meshes\n * @remarks This is used to store and manage tiles of the navigation mesh for efficient path and when obstacles are used.\n */\n private _tileCache?: TileCache;\n\n /**\n * Gets the tile cache used for tiled navigation meshes\n * @returns The tile cache instance, or undefined if not available\n */\n public get tileCache(): TileCache | undefined {\n return this._tileCache;\n }\n\n // Crowd specific properties\n private _maximumSubStepCount: number = 10;\n private _timeStep: number = 1 / 60;\n private _timeFactor: number = 1;\n\n private _crowd?: ICrowd;\n\n /**\n * Creates a RecastNavigationJSPluginV2 instance\n * @param recastInjection The recast-navigation-js injection containing core and generators\n */\n public constructor(recastInjection?: RecastInjection) {\n if (!recastInjection) {\n recastInjection = GetRecast();\n InjectGenerators(this);\n }\n\n this.bjsRECAST = recastInjection;\n\n if (!this.isSupported()) {\n Logger.Error(\"RecastJS is not available. Please make sure you included the js file.\");\n return;\n }\n this.setTimeStep();\n }\n\n /**\n * Set the time step of the navigation tick update.\n * Default is 1/60.\n * A value of 0 will disable fixed time update\n * @param newTimeStep the new timestep to apply to this world.\n */\n public setTimeStep(newTimeStep: number = 1 / 60): void {\n this._timeStep = newTimeStep;\n }\n\n /**\n * Get the time step of the navigation tick update.\n * @returns the current time step\n */\n public getTimeStep(): number {\n return this._timeStep;\n }\n\n /**\n * If delta time in navigation tick update is greater than the time step\n * a number of sub iterations are done. If more iterations are need to reach deltatime\n * they will be discarded.\n * A value of 0 will set to no maximum and update will use as many substeps as needed\n * @param newStepCount the maximum number of iterations\n */\n public setMaximumSubStepCount(newStepCount: number = 10): void {\n this._maximumSubStepCount = newStepCount;\n }\n\n /**\n * Get the maximum number of iterations per navigation tick update\n * @returns the maximum number of iterations\n */\n public getMaximumSubStepCount(): number {\n return this._maximumSubStepCount;\n }\n\n /**\n * Time factor applied when updating crowd agents (default 1). A value of 0 will pause crowd updates.\n * @param value the time factor applied at update\n */\n public set timeFactor(value: number) {\n this._timeFactor = Math.max(value, 0);\n }\n\n /**\n * Get the time factor used for crowd agent update\n * @returns the time factor\n */\n public get timeFactor(): number {\n return this._timeFactor;\n }\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParametersV2): CreateNavMeshResult {\n if (!this.createNavMeshImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = this.createNavMeshImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Creates a navigation mesh asynchronously - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public async createNavMeshAsync(meshes: Array<Mesh>, parameters: INavMeshParametersV2): Promise<CreateNavMeshResult> {\n if (!this.createNavMeshAsyncImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = await this.createNavMeshAsyncImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Create a navigation mesh debug mesh\n * @param scene is where the mesh will be added\n * @returns debug display mesh\n */\n public createDebugNavMesh(scene: Scene): Mesh {\n if (!this.navMesh) {\n throw new Error(\"There is no navMesh generated.\");\n }\n\n if (this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return CreateDebugNavMesh(this.navMesh, scene);\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getClosestPoint(\n position: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n const pr = new Vector3(ret.point.x, ret.point.y, ret.point.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getClosestPointToRef(\n position: IVector3Like,\n result: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n result.set(ret.point.x, ret.point.y, ret.point.z);\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAround(\n position: IVector3Like,\n maxRadius: number,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n const pr = new Vector3(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAroundToRef(\n position: IVector3Like,\n maxRadius: number,\n result: Vector3,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n result.set(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position position to start from\n * @param destination position to go to\n * @param startRef the reference id of the start polygon\n * @param options options for the function\n * @returns the resulting point along the navmesh\n */\n public moveAlong(\n position: IVector3Like,\n destination: IVector3Like,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n const pr = new Vector3(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n return pr;\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position world position\n * @param destination world position\n * @param result output the resulting point along the navmesh\n * @param startRef the reference id of the start polygon.\n * @param options options for the function\n */\n public moveAlongToRef(\n position: IVector3Like,\n destination: IVector3Like,\n result: Vector3,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n maxVisitedSize?: number;\n }\n ): void {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n result.set(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n }\n\n /**\n * Compute a navigation path from start to end. Returns an empty array if no path can be computed\n * Path is straight.\n * @param start world position\n * @param end world position\n * @param options options for the function\n * @returns array containing world position composing the path\n */\n public computePath(\n start: IVector3Like,\n end: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxStraightPathPoints?: number;\n }\n ): Vector3[] {\n return ConvertNavPathPoints(this._navMeshQuery.computePath(start, end, options));\n }\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param start the start position of the navmesh\n * @param end the end position of the navmesh\n * @param options options to configure the path computation\n * @returns array containing world position composing the path\n */\n public computePathSmooth(\n start: Vector3,\n end: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxSmoothPathPoints?: number;\n stepSize?: number;\n slop?: number;\n }\n ): Vector3[] {\n if (!this.navMesh) {\n Logger.Error(\"No navmesh available. Cannot compute smooth path.\");\n return [];\n }\n return ComputeSmoothPath(this.navMesh, this._navMeshQuery, start, end, options);\n }\n\n /**\n * Create a new Crowd so you can add agents\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd {\n const crowd = new RecastJSCrowd(this, maxAgents, maxAgentRadius, scene);\n this._crowd = crowd;\n return crowd;\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n public setDefaultQueryExtent(extent: IVector3Like): void {\n this._navMeshQuery.defaultQueryHalfExtents = extent;\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n public getDefaultQueryExtent(): Vector3 {\n return new Vector3(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n public getDefaultQueryExtentToRef(result: Vector3): void {\n result.set(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * build the navmesh from a previously saved state using getNavmeshData\n * @param data the Uint8Array returned by getNavmeshData\n */\n public buildFromNavmeshData(data: Uint8Array): void {\n const result = this.bjsRECAST.importNavMesh(data);\n this.navMesh = result.navMesh;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data\n * @returns data the Uint8Array that can be saved and reused\n */\n public getNavmeshData(): Uint8Array {\n if (!this.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n return this.bjsRECAST.exportNavMesh(this.navMesh);\n }\n\n /**\n * build the tile cache from a previously saved state using getTileCacheData\n * @param tileCacheData the data returned by getTileCacheData\n * @param tileCacheMeshProcess optional process to apply to each tile created\n */\n public buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void {\n const result = this.bjsRECAST.importTileCache(tileCacheData, tileCacheMeshProcess ?? CreateDefaultTileCacheMeshProcess([]));\n this.navMesh = result.navMesh;\n this._tileCache = result.tileCache;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @throws Error if there is no TileCache generated\n * @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData\n */\n public getTileCacheData(): Uint8Array {\n if (!this.navMesh || !this._tileCache) {\n throw new Error(\"There is no TileCache generated.\");\n }\n return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache);\n }\n\n /**\n * Disposes\n */\n public dispose() {\n this._crowd?.dispose();\n this.navMesh?.destroy();\n this._navMeshQuery?.destroy();\n this._tileCache?.destroy();\n }\n\n /**\n * Creates a cylinder obstacle and add it to the navigation\n * @param position world position\n * @param radius cylinder radius\n * @param height cylinder height\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addCylinderObstacle(position: IVector3Like, radius: number, height: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addCylinderObstacle(position, radius, height);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Creates an oriented box obstacle and add it to the navigation\n * @param position world position\n * @param extent box size\n * @param angle angle in radians of the box orientation on Y axis\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addBoxObstacle(position: IVector3Like, extent: IVector3Like, angle: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addBoxObstacle(position, extent, angle);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Removes an obstacle created by addCylinderObstacle or addBoxObstacle\n * @param obstacle obstacle to remove from the navigation\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n *\n */\n public removeObstacle(obstacle: IObstacle, doNotWaitForCacheUpdate = false): void {\n this._tileCache?.removeObstacle(obstacle);\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n }\n\n /**\n * If this plugin is supported\n * @returns true if plugin is supported\n */\n public isSupported(): boolean {\n return !!this.bjsRECAST;\n }\n\n /**\n * Returns the seed used for randomized functions like `getRandomPointAround`\n * @returns seed number\n */\n public getRandomSeed(): number {\n return this.bjsRECAST.getRandomSeed();\n }\n\n /**\n * Set the seed used for randomized functions like `getRandomPointAround`\n * @param seed number used as seed for random functions\n */\n public setRandomSeed(seed: number): void {\n this.bjsRECAST.setRandomSeed(seed);\n }\n\n // New funccntions beyond the INavigationEnginePlugin interface\n\n /**\n * Perform a raycast on the navmesh\n * @param start start position\n * @param end end position\n * @returns if a direct path exists between start and end, and the hit point if any\n */\n public raycast(start: IVector3Like, end: IVector3Like) {\n const nearestStartPoly = this._navMeshQuery.findNearestPoly(start);\n const raycastResult = this._navMeshQuery.raycast(nearestStartPoly.nearestRef, start, end);\n\n const hit = 0 < raycastResult.t && raycastResult.t < 1.0;\n if (!hit) {\n return {\n hit: false,\n };\n } else {\n TmpVectors.Vector3[0].set(start.x, start.y, start.z);\n TmpVectors.Vector3[1].set(end.x, end.y, end.z);\n\n const distanceToHitBorder = Vector3.Distance(TmpVectors.Vector3[0], TmpVectors.Vector3[1]) * (raycastResult?.t ?? 0);\n const direction = TmpVectors.Vector3[1].subtract(TmpVectors.Vector3[0]).normalize();\n const hitPoint = TmpVectors.Vector3[0].add(direction.multiplyByFloats(distanceToHitBorder, distanceToHitBorder, distanceToHitBorder));\n\n return {\n hit: true,\n hitPoint,\n };\n }\n }\n\n /**\n * Compute the final position from a segment made of destination-position, and return the height of the polygon\n * This is a more sophisiticated version of moveAlong that will use the height of the polygon at the end position\n * @param position world position to start from\n * @param velocity wvelocity of the movement\n * @param options options for the function\n * @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon\n */\n public moveAlongWithVelocity(\n position: IVector3Like,\n velocity: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ) {\n const { point, polyRef } = this._navMeshQuery.findClosestPoint(\n {\n x: position.x,\n y: position.y,\n z: position.z,\n },\n options\n );\n\n const { resultPosition } = this._navMeshQuery.moveAlongSurface(\n polyRef,\n point,\n {\n x: point.x + velocity.x,\n y: point.y + velocity.y,\n z: point.z + velocity.z,\n },\n options\n );\n const polyHeightResult = this._navMeshQuery.getPolyHeight(polyRef, resultPosition);\n\n return {\n position: { x: resultPosition.x, y: polyHeightResult.success ? polyHeightResult.height : resultPosition.y, z: resultPosition.z },\n polyRef: polyRef,\n height: polyHeightResult.height,\n };\n }\n\n /**\n * Handles common post-processing and validation of navmesh creation results\n * @param result The partial result from navmesh creation\n * @returns The validated and complete CreateNavMeshresult\n */\n private _processNavMeshResult(result: Nullable<Partial<CreateNavMeshResult>>): CreateNavMeshResult {\n if (!result?.navMesh || !result?.navMeshQuery) {\n throw new Error(\"Unable to create navmesh. No navMesh or navMeshQuery returned.\");\n }\n\n this.navMesh = result.navMesh;\n this._navMeshQuery = result.navMeshQuery;\n this._intermediates = result.intermediates;\n this._tileCache = result.tileCache;\n\n return {\n navMesh: result.navMesh,\n navMeshQuery: result.navMeshQuery,\n intermediates: result.intermediates,\n tileCache: result.tileCache, // tileCache is optional\n };\n }\n\n private _preprocessParameters(parameters: INavMeshParametersV2) {\n // if maxObstacles is not defined, set it to a default value and set a default tile size if not defined\n if (parameters.maxObstacles === undefined) {\n parameters.tileSize = parameters.tileSize ?? 32; // maxObstacles will trigger tile cache creation, so we need a tile size\n parameters.maxObstacles = DefaultMaxObstacles;\n }\n\n parameters.walkableSlopeAngle = Math.max(0.1, parameters.walkableSlopeAngle ?? 60);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RecastNavigationJSPlugin.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,oCAAyB;AAG1C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,mCAAwB;AAKtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iC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,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;CACJ","sourcesContent":["import type { TileCacheMeshProcess, NavMesh, QueryFilter, TileCache, NavMeshQuery } from \"@recast-navigation/core\";\n\nimport type { ICrowd, INavigationEnginePlugin, IObstacle } from \"core/Navigation/INavigationEngine\";\nimport { Logger } from \"core/Misc/logger\";\nimport type { Mesh } from \"core/Meshes/mesh\";\nimport type { Scene } from \"core/scene\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math\";\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { Nullable } from \"core/types\";\n\nimport type { CreateNavMeshResult, GeneratorIntermediates, INavMeshParametersV2, RecastInjection } from \"../types\";\nimport { RecastJSCrowd } from \"./RecastJSCrowd\";\nimport { ConvertNavPathPoints } from \"../common/convert\";\nimport { ComputeSmoothPath } from \"../common/smooth-path\";\nimport { CreateDebugNavMesh } from \"../debug/simple-debug\";\nimport { GetRecast } from \"../factory/common\";\nimport { InjectGenerators } from \"../generator/injection\";\nimport { DefaultMaxObstacles } from \"../common/config\";\nimport { CreateDefaultTileCacheMeshProcess, WaitForFullTileCacheUpdate } from \"../common/tile-cache\";\n\n/**\n * Navigation plugin for Babylon.js. It is a simple wrapper around the recast-navigation-js library. Not all features are implemented.\n * @remarks This plugin provides navigation mesh generation and pathfinding capabilities using the recast-navigation-js library\n * @remarks It supports both single-threaded and multi-threaded generation of navigation meshes.\n * @remarks The plugin can be used to create navigation meshes from meshes in a scene, compute paths, and manage crowd agents, etc.\n * @remarks It also provides methods for creating obstacles and querying the navigation mesh.\n * @see https://github.com/isaac-mason/recast-navigation-js\n */\nexport class RecastNavigationJSPluginV2 implements INavigationEnginePlugin {\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => CreateNavMeshResult;\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n */\n createNavMeshAsyncImpl: (meshes: Array<Mesh>, parameters: INavMeshParametersV2) => Promise<CreateNavMeshResult>;\n\n /**\n * recast-navigation-js injection\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public bjsRECAST: RecastInjection;\n\n /**\n * plugin name\n */\n public name: string = \"RecastNavigationJSPlugin\";\n\n /**\n * the navmesh created\n */\n public navMesh?: NavMesh;\n\n /**\n * The navmesh query created from the navmesh\n * @remarks This is used to query the navmesh for pathfinding and other navigation tasks\n */\n public get navMeshQuery(): NavMeshQuery {\n return this._navMeshQuery;\n }\n\n private _navMeshQuery!: NavMeshQuery;\n\n /**\n * Intermediates generated during the navmesh creation\n * @remarks This is used for debugging and visualization purposes.\n * @remarks You have access to vertices, indices and vertex colors to visualize the navmesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set\n * @remarks to true during navmesh generation.\n */\n private _intermediates?: GeneratorIntermediates;\n\n /**\n * Gets the intermediates generated during the navmesh creation\n * @returns The generator intermediates, or undefined if not available\n */\n public get intermediates(): GeneratorIntermediates | undefined {\n return this._intermediates;\n }\n\n /**\n * Tile cache used for tiled navigation meshes\n * @remarks This is used to store and manage tiles of the navigation mesh for efficient path and when obstacles are used.\n */\n private _tileCache?: TileCache;\n\n /**\n * Gets the tile cache used for tiled navigation meshes\n * @returns The tile cache instance, or undefined if not available\n */\n public get tileCache(): TileCache | undefined {\n return this._tileCache;\n }\n\n // Crowd specific properties\n private _maximumSubStepCount: number = 10;\n private _timeStep: number = 1 / 60;\n private _timeFactor: number = 1;\n\n private _crowd?: ICrowd;\n\n /**\n * Creates a RecastNavigationJSPluginV2 instance\n * @param recastInjection The recast-navigation-js injection containing core and generators\n */\n public constructor(recastInjection?: RecastInjection) {\n if (!recastInjection) {\n recastInjection = GetRecast();\n InjectGenerators(this);\n }\n\n this.bjsRECAST = recastInjection;\n\n if (!this.isSupported()) {\n Logger.Error(\"RecastJS is not available. Please make sure you included the js file.\");\n return;\n }\n this.setTimeStep();\n }\n\n /**\n * Set the time step of the navigation tick update.\n * Default is 1/60.\n * A value of 0 will disable fixed time update\n * @param newTimeStep the new timestep to apply to this world.\n */\n public setTimeStep(newTimeStep: number = 1 / 60): void {\n this._timeStep = newTimeStep;\n }\n\n /**\n * Get the time step of the navigation tick update.\n * @returns the current time step\n */\n public getTimeStep(): number {\n return this._timeStep;\n }\n\n /**\n * If delta time in navigation tick update is greater than the time step\n * a number of sub iterations are done. If more iterations are need to reach deltatime\n * they will be discarded.\n * A value of 0 will set to no maximum and update will use as many substeps as needed\n * @param newStepCount the maximum number of iterations\n */\n public setMaximumSubStepCount(newStepCount: number = 10): void {\n this._maximumSubStepCount = newStepCount;\n }\n\n /**\n * Get the maximum number of iterations per navigation tick update\n * @returns the maximum number of iterations\n */\n public getMaximumSubStepCount(): number {\n return this._maximumSubStepCount;\n }\n\n /**\n * Time factor applied when updating crowd agents (default 1). A value of 0 will pause crowd updates.\n * @param value the time factor applied at update\n */\n public set timeFactor(value: number) {\n this._timeFactor = Math.max(value, 0);\n }\n\n /**\n * Get the time factor used for crowd agent update\n * @returns the time factor\n */\n public get timeFactor(): number {\n return this._timeFactor;\n }\n\n /**\n * Creates a navigation mesh - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParametersV2): CreateNavMeshResult {\n if (!this.createNavMeshImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = this.createNavMeshImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Creates a navigation mesh asynchronously - will be injected by the factory\n * @param meshes array of all the geometry used to compute the navigation mesh\n * @param parameters bunch of parameters used to filter geometry\n * @returns the created navmesh and navmesh query\n * @throws Error if the function is not injected yet or if the navmesh is not created\n */\n public async createNavMeshAsync(meshes: Array<Mesh>, parameters: INavMeshParametersV2): Promise<CreateNavMeshResult> {\n if (!this.createNavMeshAsyncImpl) {\n throw new Error(\"Function not injected yet. Use the factory to create the plugin.\");\n }\n\n this._preprocessParameters(parameters);\n\n const result = await this.createNavMeshAsyncImpl(meshes, parameters);\n return this._processNavMeshResult(result);\n }\n\n /**\n * Create a navigation mesh debug mesh\n * @param scene is where the mesh will be added\n * @returns debug display mesh\n */\n public createDebugNavMesh(scene: Scene): Mesh {\n if (!this.navMesh) {\n throw new Error(\"There is no navMesh generated.\");\n }\n\n if (this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return CreateDebugNavMesh(this.navMesh, scene);\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getClosestPoint(\n position: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n const pr = new Vector3(ret.point.x, ret.point.y, ret.point.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, closest to the parameter position\n * @param position world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getClosestPointToRef(\n position: IVector3Like,\n result: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findClosestPoint(position, options);\n result.set(ret.point.x, ret.point.y, ret.point.z);\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @returns the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAround(\n position: IVector3Like,\n maxRadius: number,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n const pr = new Vector3(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n return pr;\n }\n\n /**\n * Get a navigation mesh constrained position, within a particular radius\n * @param position world position\n * @param maxRadius the maximum distance to the constrained world position\n * @param result output the closest point to position constrained by the navigation mesh\n */\n public getRandomPointAroundToRef(\n position: IVector3Like,\n maxRadius: number,\n result: Vector3,\n options?: {\n startRef?: number;\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n }\n ): void {\n const ret = this._navMeshQuery.findRandomPointAroundCircle(position, maxRadius, options);\n result.set(ret.randomPoint.x, ret.randomPoint.y, ret.randomPoint.z);\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position position to start from\n * @param destination position to go to\n * @param startRef the reference id of the start polygon\n * @param options options for the function\n * @returns the resulting point along the navmesh\n */\n public moveAlong(\n position: IVector3Like,\n destination: IVector3Like,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ): Vector3 {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n const pr = new Vector3(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n return pr;\n }\n\n /**\n * Compute the final position from a segment made of destination-position\n * @param position world position\n * @param destination world position\n * @param result output the resulting point along the navmesh\n * @param startRef the reference id of the start polygon.\n * @param options options for the function\n */\n public moveAlongToRef(\n position: IVector3Like,\n destination: IVector3Like,\n result: Vector3,\n startRef = 0,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n maxVisitedSize?: number;\n }\n ): void {\n const ret = this._navMeshQuery.moveAlongSurface(startRef, position, destination, options);\n result.set(ret.resultPosition.x, ret.resultPosition.y, ret.resultPosition.z);\n }\n\n /**\n * Compute a navigation path from start to end. Returns an empty array if no path can be computed\n * Path is straight.\n * @param start world position\n * @param end world position\n * @param options options for the function\n * @returns array containing world position composing the path\n */\n public computePath(\n start: IVector3Like,\n end: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxStraightPathPoints?: number;\n }\n ): Vector3[] {\n return ConvertNavPathPoints(this._navMeshQuery.computePath(start, end, options));\n }\n\n /**\n * Compute a navigation path from start to end. Returns an empty array if no path can be computed.\n * Path follows navigation mesh geometry.\n * @param start world position\n * @param end world position\n * @param options options to configure the path computation\n * @returns array containing world position composing the path\n */\n public computePathSmooth(\n start: Vector3,\n end: Vector3,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n maxPathPolys?: number;\n maxSmoothPathPoints?: number;\n stepSize?: number;\n slop?: number;\n }\n ): Vector3[] {\n if (!this.navMesh) {\n Logger.Error(\"No navmesh available. Cannot compute smooth path.\");\n return [];\n }\n return ComputeSmoothPath(this.navMesh, this._navMeshQuery, start, end, options);\n }\n\n /**\n * Create a new Crowd so you can add agents\n * @param maxAgents the maximum agent count in the crowd\n * @param maxAgentRadius the maximum radius an agent can have\n * @param scene to attach the crowd to\n * @returns the crowd you can add agents to\n */\n public createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd {\n const crowd = new RecastJSCrowd(this, maxAgents, maxAgentRadius, scene);\n this._crowd = crowd;\n return crowd;\n }\n\n /**\n * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)\n * The queries will try to find a solution within those bounds\n * default is (1,1,1)\n * @param extent x,y,z value that define the extent around the queries point of reference\n */\n public setDefaultQueryExtent(extent: IVector3Like): void {\n this._navMeshQuery.defaultQueryHalfExtents = extent;\n }\n\n /**\n * Get the Bounding box extent specified by setDefaultQueryExtent\n * @returns the box extent values\n */\n public getDefaultQueryExtent(): Vector3 {\n return new Vector3(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * Get the Bounding box extent result specified by setDefaultQueryExtent\n * @param result output the box extent values\n */\n public getDefaultQueryExtentToRef(result: Vector3): void {\n result.set(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z);\n }\n\n /**\n * build the navmesh from a previously saved state using getNavmeshData\n * @param data the Uint8Array returned by getNavmeshData\n */\n public buildFromNavmeshData(data: Uint8Array): void {\n const result = this.bjsRECAST.importNavMesh(data);\n this.navMesh = result.navMesh;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data\n * @returns data the Uint8Array that can be saved and reused\n */\n public getNavmeshData(): Uint8Array {\n if (!this.navMesh) {\n throw new Error(\"There is no NavMesh generated.\");\n }\n return this.bjsRECAST.exportNavMesh(this.navMesh);\n }\n\n /**\n * build the tile cache from a previously saved state using getTileCacheData\n * @param tileCacheData the data returned by getTileCacheData\n * @param tileCacheMeshProcess optional process to apply to each tile created\n */\n public buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void {\n const result = this.bjsRECAST.importTileCache(tileCacheData, tileCacheMeshProcess ?? CreateDefaultTileCacheMeshProcess([]));\n this.navMesh = result.navMesh;\n this._tileCache = result.tileCache;\n this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n }\n\n /**\n * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data\n * @throws Error if there is no TileCache generated\n * @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData\n */\n public getTileCacheData(): Uint8Array {\n if (!this.navMesh || !this._tileCache) {\n throw new Error(\"There is no TileCache generated.\");\n }\n return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache);\n }\n\n /**\n * Disposes\n */\n public dispose() {\n this._crowd?.dispose();\n this.navMesh?.destroy();\n this._navMeshQuery?.destroy();\n this._tileCache?.destroy();\n }\n\n /**\n * Creates a cylinder obstacle and add it to the navigation\n * @param position world position\n * @param radius cylinder radius\n * @param height cylinder height\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addCylinderObstacle(position: IVector3Like, radius: number, height: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addCylinderObstacle(position, radius, height);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Creates an oriented box obstacle and add it to the navigation\n * @param position world position\n * @param extent box size\n * @param angle angle in radians of the box orientation on Y axis\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n * @returns the obstacle freshly created\n */\n public addBoxObstacle(position: IVector3Like, extent: IVector3Like, angle: number, doNotWaitForCacheUpdate = false): Nullable<IObstacle> {\n const obstacleResult = this._tileCache?.addBoxObstacle(position, extent, angle);\n if (!obstacleResult?.success) {\n return null;\n }\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n\n return (obstacleResult.obstacle as IObstacle) ?? null;\n }\n\n /**\n * Removes an obstacle created by addCylinderObstacle or addBoxObstacle\n * @param obstacle obstacle to remove from the navigation\n * @param doNotWaitForCacheUpdate if true the function will not wait for the tile cache to be fully updated before returning\n *\n */\n public removeObstacle(obstacle: IObstacle, doNotWaitForCacheUpdate = false): void {\n this._tileCache?.removeObstacle(obstacle);\n\n if (!doNotWaitForCacheUpdate && this.navMesh && this._tileCache) {\n WaitForFullTileCacheUpdate(this.navMesh, this._tileCache);\n }\n }\n\n /**\n * If this plugin is supported\n * @returns true if plugin is supported\n */\n public isSupported(): boolean {\n return !!this.bjsRECAST;\n }\n\n /**\n * Returns the seed used for randomized functions like `getRandomPointAround`\n * @returns seed number\n */\n public getRandomSeed(): number {\n return this.bjsRECAST.getRandomSeed();\n }\n\n /**\n * Set the seed used for randomized functions like `getRandomPointAround`\n * @param seed number used as seed for random functions\n */\n public setRandomSeed(seed: number): void {\n this.bjsRECAST.setRandomSeed(seed);\n }\n\n // New functions beyond the INavigationEnginePlugin interface\n\n /**\n * Perform a raycast on the navmesh\n * @param start start position\n * @param end end position\n * @returns if a direct path exists between start and end, and the hit point if any\n */\n public raycast(start: IVector3Like, end: IVector3Like) {\n const nearestStartPoly = this._navMeshQuery.findNearestPoly(start);\n const raycastResult = this._navMeshQuery.raycast(nearestStartPoly.nearestRef, start, end);\n\n const hit = 0 < raycastResult.t && raycastResult.t < 1.0;\n if (!hit) {\n return {\n hit: false,\n };\n } else {\n TmpVectors.Vector3[0].set(start.x, start.y, start.z);\n TmpVectors.Vector3[1].set(end.x, end.y, end.z);\n\n const distanceToHitBorder = Vector3.Distance(TmpVectors.Vector3[0], TmpVectors.Vector3[1]) * (raycastResult?.t ?? 0);\n const direction = TmpVectors.Vector3[1].subtract(TmpVectors.Vector3[0]).normalize();\n const hitPoint = TmpVectors.Vector3[0].add(direction.multiplyByFloats(distanceToHitBorder, distanceToHitBorder, distanceToHitBorder));\n\n return {\n hit: true,\n hitPoint,\n };\n }\n }\n\n /**\n * Compute the final position from a segment made of destination-position, and return the height of the polygon\n * This is a more sophisticated version of moveAlong that will use the height of the polygon at the end position\n * @param position world position to start from\n * @param velocity velocity of the movement\n * @param options options for the function\n * @returns the resulting point along the navmesh, the polygon reference id and the height of the polygon\n */\n public moveAlongWithVelocity(\n position: IVector3Like,\n velocity: IVector3Like,\n options?: {\n /**\n * The polygon filter to apply to the query.\n */\n filter?: QueryFilter;\n /**\n * Half extents for the search box\n */\n halfExtents?: IVector3Like;\n /**\n * The maximum number of polygons the output visited array can hold.\n */\n maxVisitedSize?: number;\n }\n ) {\n const { point, polyRef } = this._navMeshQuery.findClosestPoint(\n {\n x: position.x,\n y: position.y,\n z: position.z,\n },\n options\n );\n\n const { resultPosition } = this._navMeshQuery.moveAlongSurface(\n polyRef,\n point,\n {\n x: point.x + velocity.x,\n y: point.y + velocity.y,\n z: point.z + velocity.z,\n },\n options\n );\n const polyHeightResult = this._navMeshQuery.getPolyHeight(polyRef, resultPosition);\n\n return {\n position: { x: resultPosition.x, y: polyHeightResult.success ? polyHeightResult.height : resultPosition.y, z: resultPosition.z },\n polyRef: polyRef,\n height: polyHeightResult.height,\n };\n }\n\n /**\n * Handles common post-processing and validation of navmesh creation results\n * @param result The partial result from navmesh creation\n * @returns The validated and complete CreateNavMeshresult\n */\n private _processNavMeshResult(result: Nullable<Partial<CreateNavMeshResult>>): CreateNavMeshResult {\n if (!result?.navMesh || !result?.navMeshQuery) {\n throw new Error(\"Unable to create navmesh. No navMesh or navMeshQuery returned.\");\n }\n\n this.navMesh = result.navMesh;\n this._navMeshQuery = result.navMeshQuery;\n this._intermediates = result.intermediates;\n this._tileCache = result.tileCache;\n\n return {\n navMesh: result.navMesh,\n navMeshQuery: result.navMeshQuery,\n intermediates: result.intermediates,\n tileCache: result.tileCache, // tileCache is optional\n };\n }\n\n private _preprocessParameters(parameters: INavMeshParametersV2) {\n // if maxObstacles is not defined, set it to a default value and set a default tile size if not defined\n if (parameters.maxObstacles === undefined) {\n parameters.tileSize = parameters.tileSize ?? 32; // maxObstacles will trigger tile cache creation, so we need a tile size\n parameters.maxObstacles = DefaultMaxObstacles;\n }\n\n parameters.walkableSlopeAngle = Math.max(0.1, parameters.walkableSlopeAngle ?? 60);\n }\n}\n"]}
|
package/navigation/types.d.ts
CHANGED
package/navigation/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../dev/addons/src/navigation/types.ts"],"names":[],"mappings":"AAqKA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,yBAAyB;IAClD,gBAAgB,EAAE,kBAAkB;IACpC,qBAAqB,EAAE,uBAAuB;IAC9C,sCAAsC,EAAE,wCAAwC;CACnF,CAAC","sourcesContent":["import type { NavMesh, NavMeshQuery, TileCache, TileCacheMeshProcess } from \"@recast-navigation/core\";\nimport type { SoloNavMeshGeneratorIntermediates, TileCacheGeneratorIntermediates, TiledNavMeshGeneratorIntermediates } from \"@recast-navigation/generators\";\n\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { Vector3 } from \"core/Maths/math.vector\";\nimport type { IAgentParameters, INavMeshParameters } from \"core/Navigation/INavigationEngine\";\nimport type { Nullable } from \"core/types\";\n\n/**\n * Recast injection type\n */\nexport type RecastInjection = any; // typeof import(\"@recast-navigation/core\") & typeof import(\"@recast-navigation/generators\");\n\n/**\n * Off-mesh connection data\n */\nexport interface IOffMeshConnection {\n /**\n * The start position of the off-mesh connection.\n */\n startPosition: IVector3Like;\n /**\n * The end position of the off-mesh connection.\n */\n endPosition: IVector3Like;\n /**\n * The radius of the off-mesh connection.\n */\n radius: number;\n /**\n * The type of the off-mesh connection.\n */\n bidirectional: boolean;\n /**\n * The area type of the off-mesh connection.\n */\n area: number;\n /**\n * The flags of the off-mesh connection.\n */\n flags: number;\n /**\n * The user ID of the off-mesh connection.\n * @remarks This can be used to associate the off-mesh connection with a specific user\n */\n userId?: number;\n}\n\n/**\n * Result of a navigation mesh creation.\n */\nexport type CreateNavMeshResult = Nullable<{\n /**\n * Navigation mesh\n */\n navMesh: NavMesh;\n /**\n * Navigation mesh query\n */\n navMeshQuery: NavMeshQuery;\n /**\n * Intermediates generated during the NavMesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.\n * It can be used for debugging or visualization purposes.\n */\n intermediates?: GeneratorIntermediates;\n /**\n * Tile cache generated during the NavMesh creation process.\n * @remarks This is only available if the `maxObstacles` parameter is set to a value greater than 0 in the `INavMeshParametersV2`. Defaults `maxObstacles` to 128.\n * It can be used for obstacle avoidance and dynamic navigation mesh updates.\n * @see {@link INavMeshParametersV2}\n */\n tileCache?: TileCache;\n}>;\n\n/**\n * Agent parameters\n * For actual limits and default values check the recast-navigation-js docs.\n * @see https://docs.recast-navigation-js.isaacmason.com/types/index.CrowdAgentParams.html\n */\nexport interface IAgentParametersV2 extends IAgentParameters {\n /**\n * Flags that impact steering behavior.\n */\n updateFlags: number;\n /**\n * The index of the avoidance configuration to use for the agent. [Limits: 0 to #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS inclusive]\n */\n obstacleAvoidanceType: number;\n /**\n * The index of the query filter used by this agent.\n */\n queryFilterType: number;\n /**\n * User defined data attached to the agent.\n */\n userData: unknown;\n}\n\n/**\n * NavMesh parameters\n * For actual limits and default values check the recast-navigation-js docs.\n * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html\n */\nexport interface INavMeshParametersV2 extends INavMeshParameters {\n /**\n * OffMeshConnections - Teleports\n */\n offMeshConnections?: IOffMeshConnection[];\n /**\n * Whether to keep intermediate navigation mesh data for debug visualization. Default is false.\n */\n keepIntermediates?: boolean;\n /**\n * The maximum number of obstacles that can be added to the navigation mesh. Default is 32.\n * If this value is greater then 0, the navigation mesh will be generated with a tile cache.\n */\n maxObstacles?: number;\n /**\n * The size of each tile in the tiled navigation mesh. Default is 32.\n */\n expectedLayersPerTile?: number;\n /**\n * Function which is sets the polyAreas and polyFlags for the tile cache mesh. Defaults to a function that sets all areas to 0 and flags to 1.\n */\n tileCacheMeshProcess?: TileCacheMeshProcess;\n /**\n * Don't reverse indices of the source mesh\n */\n doNotReverseIndices?: boolean;\n}\n\n/**\n * Result of a steer target computation.\n */\nexport type SteerTargetResult =\n | {\n /**\n * Indicates whether the steering target computation was successful.\n */\n success: false;\n }\n | {\n /**\n * Indicates whether the steering target computation was successful.\n */\n success: true;\n /**\n * The position to steer towards.\n */\n steerPos: Vector3;\n /**\n * The flag indicating the type of steering position.\n */\n steerPosFlag: number;\n /**\n * The reference to the polygon that the steering position is associated with.\n */\n steerPosRef: number;\n /**\n * The points that make up the path to the steering position.\n */\n points: Vector3[];\n };\n\n/**\n * Error types for path computation.\n */\nexport const ComputePathError = {\n START_NEAREST_POLY_FAILED: \"START_NEAREST_POLY_FAILED\",\n END_NEAREST_POLY_FAILED: \"END_NEAREST_POLY_FAILED\",\n FIND_PATH_FAILED: \"FIND_PATH_FAILED\",\n NO_POLYGON_PATH_FOUND: \"NO_POLYGON_PATH_FOUND\",\n NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND: \"NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND\",\n};\n\nexport type ComputePathErrorType = (typeof ComputePathError)[keyof typeof ComputePathError];\n\n/**\n * Result of a path computation.\n */\nexport type ComputePathResult = {\n /**\n * Indicates whether the path computation was successful.\n */\n success: boolean;\n /**\n * The error message if the path computation failed.\n */\n error?: {\n /**\n * A descriptive error message.\n */\n name?: string;\n /**\n * The type of error that occurred during path computation.\n * @remarks This will be one of the values from `ComputePathError`\n */\n type?: ComputePathErrorType;\n /**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../dev/addons/src/navigation/types.ts"],"names":[],"mappings":"AAqKA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,yBAAyB;IAClD,gBAAgB,EAAE,kBAAkB;IACpC,qBAAqB,EAAE,uBAAuB;IAC9C,sCAAsC,EAAE,wCAAwC;CACnF,CAAC","sourcesContent":["import type { NavMesh, NavMeshQuery, TileCache, TileCacheMeshProcess } from \"@recast-navigation/core\";\nimport type { SoloNavMeshGeneratorIntermediates, TileCacheGeneratorIntermediates, TiledNavMeshGeneratorIntermediates } from \"@recast-navigation/generators\";\n\nimport type { IVector3Like } from \"core/Maths/math.like\";\nimport type { Vector3 } from \"core/Maths/math.vector\";\nimport type { IAgentParameters, INavMeshParameters } from \"core/Navigation/INavigationEngine\";\nimport type { Nullable } from \"core/types\";\n\n/**\n * Recast injection type\n */\nexport type RecastInjection = any; // typeof import(\"@recast-navigation/core\") & typeof import(\"@recast-navigation/generators\");\n\n/**\n * Off-mesh connection data\n */\nexport interface IOffMeshConnection {\n /**\n * The start position of the off-mesh connection.\n */\n startPosition: IVector3Like;\n /**\n * The end position of the off-mesh connection.\n */\n endPosition: IVector3Like;\n /**\n * The radius of the off-mesh connection.\n */\n radius: number;\n /**\n * The type of the off-mesh connection.\n */\n bidirectional: boolean;\n /**\n * The area type of the off-mesh connection.\n */\n area: number;\n /**\n * The flags of the off-mesh connection.\n */\n flags: number;\n /**\n * The user ID of the off-mesh connection.\n * @remarks This can be used to associate the off-mesh connection with a specific user\n */\n userId?: number;\n}\n\n/**\n * Result of a navigation mesh creation.\n */\nexport type CreateNavMeshResult = Nullable<{\n /**\n * Navigation mesh\n */\n navMesh: NavMesh;\n /**\n * Navigation mesh query\n */\n navMeshQuery: NavMeshQuery;\n /**\n * Intermediates generated during the NavMesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.\n * It can be used for debugging or visualization purposes.\n */\n intermediates?: GeneratorIntermediates;\n /**\n * Tile cache generated during the NavMesh creation process.\n * @remarks This is only available if the `maxObstacles` parameter is set to a value greater than 0 in the `INavMeshParametersV2`. Defaults `maxObstacles` to 128.\n * It can be used for obstacle avoidance and dynamic navigation mesh updates.\n * @see {@link INavMeshParametersV2}\n */\n tileCache?: TileCache;\n}>;\n\n/**\n * Agent parameters\n * For actual limits and default values check the recast-navigation-js docs.\n * @see https://docs.recast-navigation-js.isaacmason.com/types/index.CrowdAgentParams.html\n */\nexport interface IAgentParametersV2 extends IAgentParameters {\n /**\n * Flags that impact steering behavior.\n */\n updateFlags: number;\n /**\n * The index of the avoidance configuration to use for the agent. [Limits: 0 to #DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS inclusive]\n */\n obstacleAvoidanceType: number;\n /**\n * The index of the query filter used by this agent.\n */\n queryFilterType: number;\n /**\n * User defined data attached to the agent.\n */\n userData: unknown;\n}\n\n/**\n * NavMesh parameters\n * For actual limits and default values check the recast-navigation-js docs.\n * @see https://docs.recast-navigation-js.isaacmason.com/types/index.RecastConfig.html\n */\nexport interface INavMeshParametersV2 extends INavMeshParameters {\n /**\n * OffMeshConnections - Teleports\n */\n offMeshConnections?: IOffMeshConnection[];\n /**\n * Whether to keep intermediate navigation mesh data for debug visualization. Default is false.\n */\n keepIntermediates?: boolean;\n /**\n * The maximum number of obstacles that can be added to the navigation mesh. Default is 32.\n * If this value is greater then 0, the navigation mesh will be generated with a tile cache.\n */\n maxObstacles?: number;\n /**\n * The size of each tile in the tiled navigation mesh. Default is 32.\n */\n expectedLayersPerTile?: number;\n /**\n * Function which is sets the polyAreas and polyFlags for the tile cache mesh. Defaults to a function that sets all areas to 0 and flags to 1.\n */\n tileCacheMeshProcess?: TileCacheMeshProcess;\n /**\n * Don't reverse indices of the source mesh\n */\n doNotReverseIndices?: boolean;\n}\n\n/**\n * Result of a steer target computation.\n */\nexport type SteerTargetResult =\n | {\n /**\n * Indicates whether the steering target computation was successful.\n */\n success: false;\n }\n | {\n /**\n * Indicates whether the steering target computation was successful.\n */\n success: true;\n /**\n * The position to steer towards.\n */\n steerPos: Vector3;\n /**\n * The flag indicating the type of steering position.\n */\n steerPosFlag: number;\n /**\n * The reference to the polygon that the steering position is associated with.\n */\n steerPosRef: number;\n /**\n * The points that make up the path to the steering position.\n */\n points: Vector3[];\n };\n\n/**\n * Error types for path computation.\n */\nexport const ComputePathError = {\n START_NEAREST_POLY_FAILED: \"START_NEAREST_POLY_FAILED\",\n END_NEAREST_POLY_FAILED: \"END_NEAREST_POLY_FAILED\",\n FIND_PATH_FAILED: \"FIND_PATH_FAILED\",\n NO_POLYGON_PATH_FOUND: \"NO_POLYGON_PATH_FOUND\",\n NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND: \"NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND\",\n};\n\nexport type ComputePathErrorType = (typeof ComputePathError)[keyof typeof ComputePathError];\n\n/**\n * Result of a path computation.\n */\nexport type ComputePathResult = {\n /**\n * Indicates whether the path computation was successful.\n */\n success: boolean;\n /**\n * The error message if the path computation failed.\n */\n error?: {\n /**\n * A descriptive error message.\n */\n name?: string;\n /**\n * The type of error that occurred during path computation.\n * @remarks This will be one of the values from `ComputePathError`\n */\n type?: ComputePathErrorType;\n /**\n * Status describing the error.\n */\n status?: number;\n };\n /**\n * The computed path as an array of Vector3 points.\n */\n path: IVector3Like[];\n};\n\n/**\n * Intermediates generated during the NavMesh creation process.\n * @remarks This is only available if the `keepIntermediates` parameter is set to true in the `INavMeshParametersV2`.\n * It can be used for debugging or visualization purposes.\n */\nexport type GeneratorIntermediates = SoloNavMeshGeneratorIntermediates | TiledNavMeshGeneratorIntermediates | TileCacheGeneratorIntermediates | null;\n"]}
|
|
@@ -51,7 +51,7 @@ export function GenerateNavMeshWorker() {
|
|
|
51
51
|
message.navMesh = navMeshExport;
|
|
52
52
|
transferables.push(navMeshExport.buffer);
|
|
53
53
|
}
|
|
54
|
-
// send
|
|
54
|
+
// send transferable message
|
|
55
55
|
self.postMessage(message, { transfer: transferables });
|
|
56
56
|
// clean up
|
|
57
57
|
result.navMesh?.destroy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navmesh-worker.js","sourceRoot":"","sources":["../../../../../dev/addons/src/navigation/worker/navmesh-worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE7G,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAGzF;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACjC,IAAI,CAAC,SAAS,GAAG,KAAK,EAAE,KAkBvB,EAAE,EAAE;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACxF,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;YACnE,OAAO;QACX,CAAC;QAED,MAAM,UAAU,EAAE,CAAC;QAEnB,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;QAEtD,iEAAiE;QACjE,wDAAwD;QACxD,iEAAiE;QACjE,8CAA8C;QAC9C,MAAM,cAAc,GAAG,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1D,MAAM,iBAAiB,GAAG,UAAU,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACrF,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,4BAA4B,CAAC,UAAU,C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BAA4B;QAC5B,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QAEvD,WAAW;QACX,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAE1B,IAAI,WAAW,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;IACL,CAAC,CAAC;AACN,CAAC","sourcesContent":["/**\n * IMPORTANT!\n * This file is still under construction and will change in the future.\n * Workers are not yet supported.\n * For more info visit: https://forum.babylonjs.com/t/replacing-recastjs-with-recast-navigation-js/56003/46\n */\nimport { exportNavMesh, exportTileCache, init as initRecast } from \"@recast-navigation/core\";\nimport type { SoloNavMeshGeneratorConfig, TileCacheGeneratorConfig, TiledNavMeshGeneratorConfig } from \"@recast-navigation/generators\";\nimport { generateSoloNavMesh, generateTileCache, generateTiledNavMesh } from \"@recast-navigation/generators\";\n\nimport { CreateSoloNavMeshConfig, CreateTileCacheNavMeshConfig } from \"../common/config\";\nimport type { INavMeshParametersV2 } from \"../types\";\n\n/**\n * Generates a navigation mesh in a web worker.\n */\nexport function GenerateNavMeshWorker() {\n self.onmessage = async (event: {\n /**\n * The data sent to the worker.\n */\n data: {\n /**\n * The positions of the vertices in the nav mesh.\n */\n positions: Float32Array;\n /**\n * The indices of the vertices in the nav mesh.\n */\n indices: Uint32Array;\n /**\n * The parameters used to configure the nav mesh generation.\n */\n parameters: INavMeshParametersV2;\n };\n }) => {\n if (!event.data || !event.data.positions || !event.data.indices || !event.data.parameters) {\n self.postMessage({ success: false, error: \"Invalid input data.\" });\n return;\n }\n\n await initRecast();\n\n const { positions, indices, parameters } = event.data;\n\n // Decide on the type of nav mesh to generate based on parameters\n // If tileSize is set, we will generate a tiled nav mesh\n // If maxObstacles is set, we will generate a tile cache nav mesh\n // Otherwise, we will generate a solo nav mesh\n const needsTileCache = (parameters.maxObstacles ?? 0) > 0;\n const needsTiledNavMesh = \"tileSize\" in parameters && (parameters.tileSize ?? 0) > 0;\n const config = needsTileCache ? CreateTileCacheNavMeshConfig(parameters) : needsTileCache ? CreateTileCacheNavMeshConfig(parameters) : CreateSoloNavMeshConfig(parameters);\n\n const result = needsTiledNavMesh\n ? needsTileCache\n ? generateTileCache(positions, indices, config as TileCacheGeneratorConfig)\n : generateTiledNavMesh(positions, indices, config as TiledNavMeshGeneratorConfig)\n : generateSoloNavMesh(positions, indices, config as SoloNavMeshGeneratorConfig);\n\n if (!result.success || !result.navMesh) {\n self.postMessage(result);\n return;\n }\n\n // prepare the transferables\n const transferables: Transferable[] = [];\n const message: {\n navMesh?: Uint8Array<ArrayBufferLike>;\n tileCache?: Uint8Array<ArrayBufferLike>;\n } = { navMesh: undefined, tileCache: undefined };\n\n // If tile cache is present, serialize it and add to the message\n if (\"tileCache\" in result && result.tileCache) {\n if (result.tileCache) {\n const tileCacheExport = exportTileCache(result.navMesh, result.tileCache);\n message.tileCache = tileCacheExport;\n transferables.push(tileCacheExport.buffer);\n }\n } else {\n // otherwise send the NavMesh\n const navMeshExport = exportNavMesh(result.navMesh);\n message.navMesh = navMeshExport;\n transferables.push(navMeshExport.buffer);\n }\n\n // send transferable message\n self.postMessage(message, { transfer: transferables });\n\n // clean up\n result.navMesh?.destroy();\n\n if (\"tileCache\" in result && result.tileCache) {\n result.tileCache.destroy();\n }\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onerjs/addons",
|
|
3
|
-
"version": "8.42.
|
|
3
|
+
"version": "8.42.8",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@onerjs/core": "8.42.
|
|
21
|
+
"@onerjs/core": "8.42.8",
|
|
22
22
|
"@dev/addons": "^1.0.0",
|
|
23
23
|
"@dev/build-tools": "^1.0.0"
|
|
24
24
|
},
|