3d-adjacency

this module outputs sets of cells of which are adjacent to one another. see .find

Source:

Methods

(inner) find(arr, opts) → {array}

find contingent clusters in a 3d array. touching entities with truthy values are considered Mass. a collection of mass is a Cluster. entites are touching IFF they share a face (that is, a piece of mass may at most have 6 adjacent neighbors)

Parameters:
Name Type Description
arr Array.<Array.<array>>
opts object
Properties
Name Type Attributes Description
isAdjacent function <optional>

custom function to decide whether cells are adjacent or not. defaults to truthy values === adjacent. fn gets cell value, and must return truthy value

Source:
Returns:

e.g. [ [{x:0,y:0,z:1}], [{x:3,y:3,z:3},{x:4,y:3,z:3}]]

Type
array

(inner) nodeSorter(ma, mb) → {number}

sorts nodes. see sort

Parameters:
Name Type Description
ma object

{ x, y, z } node

mb object

{ x, y, z } node

Source:
Returns:

-1/0/1

Type
number

(inner) sort(clusterSet) → {array}

sort a cluster set, where x, y, z values rank higher in the sort, respectively

Parameters:
Name Type Description
clusterSet Array.<array>

array of clusters

Source:
Returns:

sorted clusterSet

Type
array