假设我有2 SCNNodes node1和node2。
我想让node1有一个node1.position = SCNVector3(0, 0, 0)的职位
我想让node2有一个node2.position = SCNVector3(0, 0, 1)的职位
现在,我想让node2围绕着node1旋转。因此,我尝试这样做,node2.pivot = self.phone.pivot = SCNMatrix4MakeTranslation(0, 0, -1)。
这提供了它围绕node1旋转的地方,如果我按Pi/2旋转node2,那么它就在节点的顶部,也就是说,如果我旋转node1.rotate(Double.pi/2, 0, 0),它实际上是在node1之上。
我怎样才能使ndoe2在node1周围转到哪里呢?
Edit1:
self.container = SCNNode()
self.container.position = SCNVector3(0, 0, 0)
self.node2 = SCNNode(geometry: geom2)
self.node2.position = SCNVector3(0, 0, 1)
self.container.addChildNode(self.node2)
let constraint = SCNLookAtConstraint(target: self.node2)
constraint.isGimbalLockEnabled = false
self.node1 = SCNNode(geometry: geom)
self.node1.position = SCNVector(0, 0, 0)
self.node1.constraints = [constraint]Node1从不移动,就像node2从不移动一样。也就是说,node2总是在(0, 0, 1)位置,因为容器是唯一旋转的东西。
发布于 2018-11-30 13:46:50
如果您根本不想处理pivot元素,请使用节点层次结构。
像这样的东西应该能起作用
- node1
|
| - rotation center
| - node 2然后旋转中心,而不是直接的节点2。因为节点总是围绕着它的坐标中心旋转,而节点的坐标空间总是相对于它的父节点,所以这种方法工作得很好。
https://stackoverflow.com/questions/53551009
复制相似问题