我通过在每个更新周期施加扭矩来沿着Z旋转SCNNode和SCNPhysics主体 .
func renderer(renderer: SCNSceneRenderer, updateAtTime time: NSTimeInterval) {
print(box.presentationNode.rotation)
box.physicsBody?.applyTorque(SCNVector4(0, 0, 1, 0.06), impulse: false)
}
此外,每个更新周期我都会打印出presentationNode的轮换 . 我所看到的对我来说没有意义 . 打印输出看起来像这样,浓缩与......
SCNVector4(x:0.0,y:0.0,z:0.0,w:0.0)
SCNVector4(x:0.0,y:0.0,z:1,w:0.4)
SCNVector4(x:0.0,y:0.0,z:1,w:0.9)
...
SCNVector4(x:0.0,y:0.0,z:1,w:4.18)
SCNVector4(x:0.0,y:0.0,z:-1,w:2.09)
SCNVector4(x:0.0,y:0.0,z:-1,w:1.97)
...
SCNVector4(x:0.0,y:0.0,z:1,w:0)
SCNVector4(x:0.0,y:0.0,z:1,w:0.1)
SCNVector4(x:0.0,y:0.0,z:1,w:0.23)
...
SCNVector4(x:0.0,y:0.0,z:1,w:4.18)
SCNVector4(x:0.0,y:0.0,z:-1,w:2.09)
因此,旋转'w'从0变为4.18然后在1更新周期中变为2.09并开始向下计数,其中z为负数 . 当'w'减少到零时,z变为正数,并再次计数到4.18 .
This is not the same numbers you get if you rotate the box with a SCNAction and print the results
当你像这样旋转
box.runAction(SCNAction.rotateByX(0, y: 0, z: 50, duration: 100))
'w'从0.0到6.28(2pi),然后倒计数到零(这是更有意义的) . 打印出来的样子浓缩了
SCNVector4(x:0.0,y:0.0,z:0.0,w:0.0)
SCNVector4(x:0.0,y:0.0,z:1,w:0.4)
...
SCNVector4(x:0.0,y:0.0,z:1,w:6.28)
SCNVector4(x:0.0,y:0.0,z:-1,w:6.21)
SCNVector4(x:0.0,y:0.0,z:-1,w:6.15)
...
SCNVector4(x:0.0,y:0.0,z:1,w:0.0)
如果我的要求不清楚或者你看到不同的结果,请告诉我 .
谢谢