A container for index data describing how vertices connect to define a three-dimensional object, or geometry.
- iOS 8.0+
- macOS 10.8+
- tvOS 9.0+
- watchOS 2.0+
You use geometry elements together with
SCNGeometry objects to define custom
SCNGeometry objects or to inspect the data that composes an existing geometry. You create a custom geometry using a three-step process:
Create one or more
SCNGeometryobjects, each of which defines per-vertex information such as position, surface normal, or texture coordinates for all vertices in the geometry.
Create at least one
SCNGeometryobject, containing an array of indices identifying vertices in the geometry sources and describing the drawing primitive that SceneKit uses to connect the vertices when rendering the geometry.
SCNGeometryinstance from the geometry sources and geometry elements.
When SceneKit renders a geometry, each geometry element corresponds to a drawing command sent to the GPU. Because different rendering states require separate drawing commands, you can define a geometry using multiple geometry elements. For example, the teapot geometry shown below has four geometry elements, so you can assign up to four
SCNMaterial objects in order to render each element with a different appearance. But because each drawing command incurs a CPU time overhead when rendering, minimizing the number of elements in a custom geometry can improve rendering performance.