SCNAction.rotateByAngle rotation is inverted in El Capitan or Metal

别来无恙 提交于 2019-12-08 01:44:58

问题


Using SCNAction.rotateByAngle(…) in my game I would press left/right/up/down keys or swipe to have an object rotate in that direction. But testing my game on El Capitan or with Metal as the renderer causes the 3D object to rotate the other way i.e. left becomes right and up becomes down.

I haven't found any documentation mentioning that the rotation is "inverted" or "reversed" in El Capitan or Metal.

The code is:

Rotate up = SCNVector3(x:1, y:0, z:0)
Rotate down = SCNVector3(x:-1, y:0, z:0)
Rotate left = SCNVector3(x:0, y:1, z:0)
Rotate right = SCNVector3(x:0, y:-1, z:0)
SCNAction.rotateByAngle(CGFloat(M_PI_2), aroundAxis:vector, duration:1)

Pretty simple and straight forward.

Any clues why this is happening?

Should I have to check which OS is running or Metal and then apply the correct rotations?

thx


回答1:


In the Apple Developer Forums, an Apple employee has confirmed this.

Apple Developer Forum question & answer

This is right. The behavior on rotateByAngle was wrong (inverted) before 10.11 and iOS9 and it is fixed now. The backward compatibility is ensured (an application linked before iOS9 / 10.11 will continue to run the same). If you are building a new application and using this API and want to support previous builds, then yes you will have to check the version of the OS you are running. Another option is to use the "rotateByX:y:z:duration:" variant.



来源:https://stackoverflow.com/questions/33378583/scnaction-rotatebyangle-rotation-is-inverted-in-el-capitan-or-metal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!