IAStarRunner | Matterport SDK
Usage of the SDK constitutes your agreement with the Matterport SDK Agreement. Email developers@matterport.com with any questions.

An object that encapsulates a graph and can be used to execute A* or subscribe to A* for potential changes.

Type parameters

  • T

Hierarchy

  • IAStarRunner

Index

Methods

dispose

  • dispose(): void
  • Release resources associated with the runner. This function should be called once you are done with the runner.

    Returns void

exec

  • Do the A* search.

    Parameters

    • Optional timeout: undefined | number

      The amount of time to spend trying to find a path. Defaults to 5000ms.

    Returns Graph.AStarResult<T>

    The results of running A*.

    const aStarRunner = mpSdk.Graph.createAStarRunner(...);
    const result = aStarRunner.exec();
    if (result.status === mpSdk.Graph.AStarStatus.SUCCESS) {
      console.log('found a path of length', result.path.length);
    }
    

subscribe

  • Subscribe to changes in the underlying graph and receive a callback in observer when changes are detected.

    Parameters

    Returns ISubscription

    A subscription to stop listening for changes to the graph.

    const aStarRunner = mpSdk.Graph.createAStarRunner(...);
    const subscription = aStarRunner.subscribe({
      onChanged(runner) {
        const result = runner.exec();
        if (result.status === mpSdk.Graph.AStarStatus.SUCCESS) {
          console.log('found a path of length', result.path.length);
        }
      }
    });
    // ... some time later when the runner is no longer needed
    subscription.cancel();