Type Method

geometrySourceWithData:semantic:vectorCount:floatComponents:componentsPerVector:bytesPerComponent:dataOffset:dataStride:

Creates a geometry source from the specified data and options.

Declaration

+ (instancetype)geometrySourceWithData:(NSData *)data semantic:(SCNGeometrySourceSemantic)semantic vectorCount:(NSInteger)vectorCount floatComponents:(BOOL)floatComponents componentsPerVector:(NSInteger)componentsPerVector bytesPerComponent:(NSInteger)bytesPerComponent dataOffset:(NSInteger)offset dataStride:(NSInteger)stride;

Parameters

data

The data for the geometry source.

semantic

The semantic value (or attribute) that the geometry source describes for each vertex. See Geometry Semantic Identifiers for available values.

vectorCount

The number of geometry source vectors.

floatComponents

A Boolean value that indicates whether vector components are floating-point values. Specify YES for floating-point values, or NO for integer values.

componentsPerVector

The number of scalar components in each vector.

bytesPerComponent

The size, in bytes, of each vector component.

offset

The offset, in bytes, from the beginning of the data to the first vector component to be used in the geometry source.

stride

The number of bytes from each vector to the next in the data.

Return Value

A new geometry source object.

Discussion

A geometry source’s data is an array of vectors, each of which represents a particular attribute (or semantic) of a vertex in the geometry. The other parameters determine how SceneKit interprets this data. For example, an array of vertex positions may have three 32-bit floating-point components per vector, but an array of texture coordinates may have two 8-bit integer coponents per vector. You can use the offset and stride parameters together to interleave data for multiple geometry sources in the same array, improving rendering performance. See SCNGeometrySource for details.

To create a custom SCNGeometry object from the geometry source, use the geometryWithSources:elements: method.

See Also

Creating Geometry Sources

+ geometrySourceWithVertices:count:

Creates a geometry source from an array of vertex positions.

+ geometrySourceWithNormals:count:

Creates a geometry source from an array of normal vectors.

+ geometrySourceWithTextureCoordinates:count:

Creates a geometry source from an array of texture coordinate points.