sceneView projectPoint after changing eulerAngles

38 views Asked by At

I'm working on an app that shows location-based AR using ARKit-CoreLocation. I have 2 SCNNodes: a sceneNode and a visibleNode (which is a visible AR element) as a child.

sceneNode.addChildNode(visibleNode)

There are instances where I need to align the AR with other UI elements in the app. In order to do it, I rotate my sceneNode by 1 degree and check the position of the visibleNode until it is centered on the screen. I do something like this in my SCNView:

// 1. visibleNode x,y before rotating sceneNode
let nodePositionBefore = self.projectPoint(visibleNode.position)

// 2. rotate sceneNode
sceneNode?.eulerAngles.y -= Float(1).degreesToRadians

// 3. visibleNode x,y after rotating sceneNode
let nodePositionAfter = self.projectPoint(visibleNode.position)

When I run the code, I see the visibleNode moving left/right on the screen. But if I look at nodePositionBefore and nodePositionAfter they are exactly the same value.

What am I missing?

0

There are 0 answers