CollectionAPI¶
Description¶
Collections store groups of nodes. Collections can be created empty or from a list of nodes. Collections can also be created by searching nodes matching a given property.
- addToCollection(collectionID, nodeID, recursive)¶
Adds the Node given by nodeID to the collection with ID collectionID. If recursive is true, the descendants of the node are also added. Returns the number of nodes in the collection.
- Arguments
collectionID (
number()
) – Specifies to which collection the node should be addednodeID (
number()
) – Specifies which node should be added to the collectionrecursive (
boolean()
) – Specifies if the children of the node should also be added to the collection Optional- Returns
void – The new number of nodes in the collection
- createCollection(nodeIDlist)¶
Returns the ID of a new Collection containing the nodes from the given list.
- Arguments
nodeIDlist (
Array
) – An array of node ID’s from which a new node collection should be created Optional- Returns
number – The ID from the newly created node collection
- createCollection()¶
Creates a new, empty Collection of nodes and returns its ID.
- Returns
number – The ID from the newly created collection
- getCollection(collectionID)¶
- Arguments
collectionID (
number()
) –- Returns
ICollection
- getCollectionElements(collectionID)¶
readonly
Returns a JavaScript array containing the IDs of the nodes in the collection. Modifying the returned array results in undefined behavior.
- Arguments
collectionID (
number()
) – The ID of the node collection- Returns
Promise<Array<number>> – Array of node IDs representing the node collection
- getCollectionNodeCount(collectionID)¶
- Arguments
collectionID (
number()
) –- Returns
Promise<number>
- removeCollection(collectionID)¶
- Arguments
collectionID (
number()
) –- Returns
void
- removeFromCollection(collectionID, nodeID, recursive)¶
Removes the Node given by nodeID from the collection with ID collectionID. If recursive is true, the descendants of the node are also removed. Returns the number of nodes in the collection.
- Arguments
collectionID (
number()
) – Specifies from which collection the node should be removednodeID (
number()
) – Specifies which node should be removed from the collectionrecursive (
boolean()
) – Specifies whether the children of the node should be removed from the collection too Optional- Returns
void – The new number of nodes in the collection
- searchByVolume(selectionBox, includeOverlappingNodes, rootNodeID)¶
Finds nodes within the given BoxVolume (created using the createBoxVolume() function). If includeOverlappingNodes is false, only nodes fully contained by the box volume are returned. The rootNodeID specifies the node from which the subtree is searched.
- Arguments
selectionBox – (BoxVolume ) 3-dimensional search volume
includeOverlappingNodes (
boolean()
) – Specifies whether the search result contains only those nodes which lie entirely in the search volume or if overlapping nodes are also includedrootNodeID (
number()
) – Restricts the search to a subtree of a node with the given ID Optional- Returns
Promise<number> – The search result is a collection whose ID is returned by the search function