CostTable()

A lookup table representing the cost associated from traveling from one node to every other node in the navgiation mesh's graph.

new CostTable()

Creates a new cost table.

Author:

Methods

clear() → {CostTable}

Clears the cost table.

Returns:
CostTable -

A reference to this cost table.

fromJSON(json) → {CostTable}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
CostTable -

A reference to this cost table.

get(from, to) → {Number}

Returns the cost for the given pair of navigation nodes.

Parameters:
Name Type Description
from Number

The start node index.

to Number

The destintation node index.

Returns:
Number -

The cost.

init(navMesh) → {CostTable}

Inits the cost table for the given navigation mesh.

Parameters:
Name Type Description
navMesh NavMesh

The navigation mesh.

Returns:
CostTable -

A reference to this cost table.

set(from, to, cost) → {CostTable}

Sets the cost for the given pair of navigation nodes.

Parameters:
Name Type Description
from Number

The start node index.

to Number

The destintation node index.

cost Number

The cost.

Returns:
CostTable -

A reference to this cost table.

size() → {Number}

Returns the size of the cost table (amount of entries).

Returns:
Number -

The size of the cost table.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.