确定SCNBox的哪一侧被触摸,Scene Kit iOS [英] Determine which side of SCNBox got touched, Scene Kit ios
问题描述
我正在使用Scene Kit,并创建了一个SCNBox。在框的前面,我希望这样,如果单击前面的左侧,则发生 A,如果单击前面的右侧,则发生 B。我该如何实现。我检查了堆栈,但是大多数答案都涵盖了是否触摸到某个节点,而不是该节点的一部分。
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.
推荐答案
SCNHitTestResult
具有 geometryIndex
,它将为您提供被击中的几何 element (即立方体面)的索引。它还具有 faceIndex
属性,将为您提供该元素中原始元素的索引。
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.
这篇关于确定SCNBox的哪一侧被触摸,Scene Kit iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!