childNodes(passingTest:)
Returns all nodes in the node’s child node subtree that satisfy the test applied by a block.
Declaration
func childNodes(passingTest predicate: (SCNNode, UnsafeMutablePointer<ObjCBool>) -> Bool) -> [SCNNode]Parameters
- predicate:
The block to apply to the node’s child and descendant nodes.
The block takes two parameters:
- child
The child node currently being searched.
- stop
A reference to a Boolean value. Set
*stopto True in the block to abort further processing of the child node subtree.
The block returns a Boolean value indicating whether to include the
childnode in the search results array.
Return Value
An array containing nodes that passed the test.
Discussion
Use this method to search for nodes using a test you specify. For example, you can search for empty nodes using a block that returns YES for nodes whose light, camera, and geometry properties are all nil.
SceneKit uses a recursive preorder traversal to search the child node subtree—that is, the block searches a node before it searches each of the node’s children, and it searches all children of a node before searching any of that node’s sibling nodes.