Syncromesh/Navigation
Query-based waypoint generation with detailed path diagnostics for dynamic obstacle fields.
Run these queries in the authoritative board that owns the relevant physics world. Waypoints are local path results; routing between board regions remains application logic.
Provides local path planning for moving entities. The runtime samples nearby physics obstacles, attempts direct movement first, then falls back to a tangent/visibility-graph solve. Use generateWaypoints when you only need points to enqueue, or diagnoseWaypoints when you need solver telemetry for debugging and tooling.
Import #
import * as Navigation from 'Syncromesh/Navigation';Functions #
generateWaypoints
Returns ordered waypoint points from
from toward to.- The result can be direct, solved, or partial depending on obstacle layout and configured limits.
- Returns an empty array when no path segment can be produced.
generateWaypoints(from: Point, to: Point, options?: NavigationQueryOptions): Promise<Point[]>diagnoseWaypoints
Runs the same solver and returns status, reason, costs, stage breakdown, and optional debug geometry.
statusandreasonare stable enum-like keys intended for tests and telemetry.debugarrays are always present; they are empty unless the solver emits corresponding geometry.
diagnoseWaypoints(from: Point, to: Point, options?: NavigationQueryOptions): Promise<NavigationDiagnostics>Query options #
NavigationQueryOptions
Optional controls for obstacle inflation, graph size caps, and diagnostics verbosity.
agentRadiusnumber optional - Agent collision radius. Default0.55.formationRadiusnumber optional - Extra formation spacing radius added to clearance. Default0.safetyMarginnumber optional - Additional inflation margin. Default0.05.maxDetourDistancenumber optional - Maximum allowed routed distance extension over direct distance. Default64.maxObstacleCountnumber optional - Obstacle cap for one solve. Minimum1. Default64.maxCandidatesnumber optional - Candidate point cap. Alias formaxCandidateCount. Minimum2. Default128.maxCandidateCountnumber optional - Equivalent tomaxCandidates.maxEdgesnumber optional - Visibility edge cap. Alias formaxEdgeCount. Minimum1. Default512.maxEdgeCountnumber optional - Equivalent tomaxEdges.smoothingPassesnumber optional - Line-of-sight smoothing passes after A*. Default2.includeDebugGeometryboolean optional - Includes inflated obstacle proxies, candidate points, and edge sets in diagnostics. Defaultfalse.includeRejectedEdgesboolean optional - When debug geometry is enabled, also records rejected visibility edges. Defaultfalse.ignoreEntitiesnumber[] optional - Entity ids to exclude from obstacle discovery for this query.ignoreEntityIdsnumber[] optional - Alias forignoreEntities.ignoreWeldedAttachedEntitiesboolean optional - When true, welded bodies attached to any ignored entity are excluded too. Defaulttrue.
Diagnostics shape #
NavigationDiagnostics
Full result object returned by
diagnoseWaypoints.statusstring - One of the status keys listed below.reasonstring - Stable reason key for solved/partial/failed outcomes.waypointsPoint[] - Ordered path points to enqueue.queryNavigationQuerySummary - Resolved query values used by the solver.costNavigationCost - Performance and graph-size counters for the solve.stagesNavigationStage[] - Stage-by-stage solve summary (directSweep,cluster,visibilityGraph,astar,smoothing).debugNavigationDebug - Debug geometry payload (arrays may be empty).
NavigationQuerySummary
Effective query values after option parsing.
fromPoint - Start point.toPoint - Target point.agentRadiusnumber - Agent radius used for this solve.formationRadiusnumber - Formation radius used for this solve.clearancenumber - Computed obstacle inflation (agentRadius + formationRadius + safetyMargin).
NavigationCost
Solve telemetry counters.
elapsedMicrosnumber - Solver wall-clock duration in microseconds.obstaclesConsiderednumber - Obstacle proxies considered in this query region.candidatesGeneratednumber - Candidate graph nodes generated (excluding start/target).visibilityEdgesTestednumber - Visibility segment checks performed.graphNodesnumber - Total graph nodes in the solve.graphEdgesnumber - Visible graph edges accepted.
NavigationStage
One solver stage entry.
namestring - Stage name.statusstring - Stage-local status key.blockerCountnumber optional - Blocking obstacle count for sweep stages.clusterCountnumber optional - Obstacle cluster size.nodeCountnumber optional - Graph node count.edgeCountnumber optional - Graph edge count.visitedNodesnumber optional - A* visited node count.removedWaypointsnumber optional - Smoothing pass removals.
NavigationDebug
Optional geometry emitted for diagnostics.
directSegmentPoint[] - Input direct segment endpoints (from,to).inflatedObstaclesNavigationDebugObstacle[] - Inflated obstacle proxies used by the solve.candidatePointsPoint[] - Graph candidate points after filtering.chosenEdgesArray<[Point, Point]> - Visible edges accepted into the graph.rejectedEdgesArray<[Point, Point]> - Visibility edges rejected (only whenincludeRejectedEdgesis true).
Status keys #
| Key | Meaning |
|---|---|
direct | Direct movement segment is clear; no detour graph required. |
solved | Visibility-graph solve reached the target. |
partial | Only partial progress was produced (for example adjusted target or clipped detour). |
failed | No movement segment could be produced by the solver. |
limit_exceeded | Solve aborted because configured caps were exceeded. |
Reason keys #
| Key | Meaning |
|---|---|
none | No failure condition (successful direct/solved path). |
start_blocked | Start point remained blocked after escape attempts. |
target_blocked | Target point was blocked and required adjustment, or remained blocked. |
direct_blocked | Direct segment blocked and no better reason chosen. |
no_visible_edges | Visibility graph had no viable edges between start and target neighborhoods. |
astar_no_path | Graph built, but A* could not connect to target (or returned partial fallback progress). |
max_obstacles_exceeded | Obstacle cap exceeded. |
max_candidates_exceeded | Candidate point cap exceeded. |
max_edges_exceeded | Edge test/edge count cap exceeded. |
max_detour_exceeded | Route exceeded allowed detour budget and was clipped to partial. |
Example #
import * as Navigation from 'Syncromesh/Navigation';
import * as Entity from 'Syncromesh/Entity';
const from = await Entity.getPosition(unitId);
const to = { x: 20, y: -8 };
const diagnostics = await Navigation.diagnoseWaypoints(from, to, {
agentRadius: 0.55,
maxDetourDistance: 24,
maxCandidates: 160,
maxEdges: 1400,
includeDebugGeometry: true
});
for (const waypoint of diagnostics.waypoints)
{
await Entity.enqueueWaypoint(unitId, waypoint);
}
// Telemetry keys are stable for tooling.
// diagnostics.status: direct | solved | partial | failed | limit_exceeded
// diagnostics.reason: none | start_blocked | target_blocked | ...