SCNAction.rotateByAngle inverted rotation in El Capitan

Hi,


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


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.


Did I miss something regarding SceneKit for El Capitan?

Same thing also happens with iOS 9/Metal...


Any clues why this is happening?

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


thx

MKX

Replies

Hi MKX,


Would you be able to provide the value of 'vector'. It is not defined in the code above.

Or, are you stating that when 'vector' is set to any of the values of 'up', 'left' and so on you are seeing a reversal of direction?


Cheers

Hi greven,

Sorry the SCNVector3... "up", "down", "left" and "right" is the "vector" I mean in my example basically. And thats is a yes to your qeustion as well. What was rotate "left" on Yosemite and iOS 8 is now rotate "right" in El Capitan and iOS 9. But since I will be targeting El Capitan+ and iOS 9+ this won't be an issues anymore – but it was strange when I did upgrade by devices and saw that the user interaction was reversed. And I made pretty sure not to commit any code or do any changes before and after the upgrade, just to be as safe as possible for testing.

This is the code

let rotateAction = SCNAction.rotateByAngle(3.14159265359, aroundAxis:SCNVector3(x:0, y:0, z:1), duration:1)

rotateAction.timingMode = SCNActionTimingMode.Linear

torusNode.runAction(SCNAction.repeatActionForever(rotateAction))


and here are two screen recordings for iOS 8.4 and iOS 9 – you can see that the torus is rotating in opposite direction.

https://dl.dropboxusercontent.com/u/6979623/iOS8.mov

https://dl.dropboxusercontent.com/u/6979623/iOS9.mov

Hi MKX,


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.