Instance Method


Adds an object to the tree corresponding to the specified volume of 3D space.


func add(_ element: ElementType, in box: GKBox) -> GKOctreeNode



The object to add to the tree.


The axis-aligned bounding volume in 3D space to which the object corresponds.

Return Value

The tree node containing the newly added object.


The GKOctree class automatically creates nodes to manage the objects you add to the tree. If you expect to remove an element you’ve added, keep a reference to the node this method returns so you can use the remove(_:using:) method to remove that object quickly.

See Also

Adding and Removing Elements

func add(ElementType, at: vector_float3) -> GKOctreeNode

Adds an object to the tree corresponding to the specified point in 3D space.

func remove(ElementType, using: GKOctreeNode) -> Bool

Removes the specified object from the tree, using a reference to its containing node.

func remove(ElementType) -> Bool

Searches for the specified object and removes it from the tree.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software