I am using Scene Kit and have created an SCNBox. On the front face of the box I want it so "A" happens if the left side of the front face gets clicked, and "B" happens if the right side of the front face gets clicked. How can I achieve this. I checked on stack but most answers cover if a node gets touched, not part of a node.
Asked
Active
Viewed 821 times
3
-
Possible duplicate of [identify face of a cube hit on touches began in Swift-Scene Kit](http://stackoverflow.com/questions/35153302/identify-face-of-a-cube-hit-on-touches-began-in-swift-scene-kit) – rickster Apr 21 '16 at 18:24
1 Answers
6
SCNHitTestResult
has a geometryIndex
that will give you the index of the geometry element that was hit (i.e. the cube face). It also has a faceIndex
property that will give you the index of the primitive in this element.

mnuages
- 13,049
- 2
- 23
- 40
-
-
Please could anyone explain to me what is meant by "index of the primitive" for the "faceIndex" property? – HusseinB Sep 22 '17 at 09:17
-
1A `SCNGeometryElement` is made of several [primitives](https://developer.apple.com/documentation/scenekit/scngeometryprimitivetype) (triangles, quads, etc.) and `faceIndex` gives you the index (in the range `[0, primitiveCount-1]`) for the primitive that was hit – mnuages Sep 22 '17 at 18:36