1

I opened a .dae in Xcode to show it in SceneKit. Everything worked fine.

To add some nodes, I converted it automatically with Xcode to .scn format.

However, when I now run the app, the model is rotated by 90 degrees, probably because the y axis is orientated differently.

Is there an option, to fix this, without manually rotating everything back by 90 degrees?

Sure, I could set Euler angle for XZY 270 degrees. However, that's no clean solution, since I would also have to adjust the params for any operations I'm doing with the model. Is there a way, to set this 270 degrees to new default = 0 degrees?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Pascal
  • 2,590
  • 3
  • 21
  • 46

1 Answers1

1

The rotation, eulerAngles, and orientation properties – all affect the rotational aspect of the node’s transform property. Any change to one of these properties is reflected in the others.

var rotation: SCNVector4 { get set }
var eulerAngles: SCNVector3 { get set }
var orientation: SCNQuaternion { get set }

Try to change the order of components (xyz) in vector matches (eulerAngles) the axes of rotation. For macOS xyz fields are of type CGFloat and for iOS they are of type Float.

The order of components in this vector matches the axes of rotation:

  1. Pitch (X component) is the rotation about the node’s X-axis.

  2. Yaw (Y component) is the rotation about the node’s Y-axis.

  3. Roll (Z component) is the rotation about the node’s Z-axis.

SceneKit applies these rotations relative to the node’s pivot property in the reverse order of the components:

  1. first Roll,
  2. then Yaw,
  3. then Pitch.

The best solution is to prepare your 3D model with ZYX rotation order in 3D package.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220