textureCoordinates(withMappingChannel:)
Returns the texture coordinates at the point of intersection for the specified texture mapping channel.
Declaration
func textureCoordinates(withMappingChannel channel: Int) -> CGPointParameters
- channel:
The index of the mapping channel in which to look up texture coordinates.
Return Value
The texture coordinates at the point of intersection, or CGPointZero if the geometry does not have a texture coordinate source for the specified channel.
Discussion
An SCNGeometry object can contain multiple sources of texture coordinates, or texture mapping channels. (With multiple channels, you can map texture images for different material properties in different ways.) To use the texture coordinates of a hit-test result, specify which texture coordinate source to look up coordinates in.
For example, to add “scorch marks” to a game character hit by a laser, you might modify a texture image mapped to the multiply property of the geometry’s material. Use the mappingChannel index from that material property as the channel parameter when calling textureCoordinates(withMappingChannel:) to ensure that you modify the correct location in the texture image.