获取SCNNode面临的方向 [英] Getting direction that SCNNode is facing
问题描述
我迷失了如何在Scenekit中处理节点空间的坐标和旋转.
I am getting lost in how nodespace coordinates and rotation are handled in scenekit.
旋转后如何获得节点朝向的方向,然后再向该方向施加力.
How do I get the direction a node is facing after rotation so I can then apply force in that direction.
我假设沿着-z轴施加到节点上的力总是会使它相对于节点向前移动,但是事实并非如此.
I assumed that a force along the -z axis applied to the node would always move it forward relative to the node however this is not the case.
推荐答案
负z仅是节点在其自身坐标空间(即其子级和几何体所在的坐标空间)中的面向"方向.施加力时,您正在包含节点的坐标空间中工作.
Negative z is the "facing" direction of a node only in its own coordinate space (i.e. the one its children and geometry are positioned in). When you apply a force, you're working in the coordinate space containing the node.
因此,如果要在节点的向前方向上施加力,则需要使用convertPosition:toNode:
So, if you want to apply a force in a node's forward direction, you'll need to convert a vector like {0,0,-1}
from the node's space to its parent's using a method like convertPosition:toNode:
.
这篇关于获取SCNNode面临的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!