0

I'm not sure of the correct terminology to describe this issue so I've posted two pictures demonstrating the problem.

When using 3D models authored in 3rd party packages like SketchUp, you might encounter grouped geometry (childnodes) that are not aligned to the parent node axis. The picture below shows a top view of a model of Da Vinci wooden Odometer with 4 wheels (2 wheels for moving the cart & another 2 wheels for measuring the distanced travelled).

3 wheels in this model are not aligned with any of the rootNodes 3-axis. So when you do a rotation like say

 let rotateAction = SCNAction.rotate(by: 20, around: SCNVector3(1,0,0), duration: 10)

 let rotateForever = SCNAction.repeatForever(rotateAction)

 wheelNode?.runAction(rotateForever)

the wheel will not rotate on its centre (even if the wheelNodes pivot is in the centre of the wheel Geometry) because the wheels orientation is not aligned to the x-axis.

enter image description here

I know one way to make it work... is you can manually rotate the geometry around so all 4 wheels now are aligned with at least a primary axis.

enter image description here

But is there a way to do this using swift instead.

  1. Detect a childnodes mis-alignment to the primary axis of rotation say x-axis..... and re-align either the childnode or whole model at run-time so its align with a primary axis.

Is it possible to do this sort of thing with wheelNode.rotateBy instead?

Any help would be appreciated.

Clay
  • 1,721
  • 2
  • 10
  • 18
  • 1
    Not sure I understand correctly, but it seems like you are asking for a workaround in swift rather than a solution for what you actually want to do. So to clarify, what it the end goal? It seems what you call a primary axis is an axis in world space, or in parent node space, and you just want to rotate a child node in its own local space rather than its parent's. – Xartec Feb 22 '18 at 18:25
  • Ok.... that makes sense. I will look at rotating my child in its own local coordinate space rather than its parents! [rotate scnnode relative to local coordinates](https://stackoverflow.com/questions/45357020/rotate-scnnode-relative-local-coordinates) – Clay Feb 22 '18 at 20:34

0 Answers0