0

I have two SCNNodes in the ARView-Scene. Let's say Object1 and Object2. Object1 is placed next to Object2. I have a button that puts one object to the right of the other "Move to the right". If I want to move Object1 to the right of Object2, I just need to change the x-Axis of Object1.

But if I move the camera to another position, it still moves it to the x-Axis, which is not correct. It for example should change the z-Axis or even both.

                let diff = calculateNodeDifference(nodeA: target, nodeB: Item.currentObject)
                let position1x = String(describing:diff.x + 0.5)
                let position1y = String(describing:diff.y)//String(describing:myNode.parent!.boundingBox.max.y)
                let position1z = String(describing:diff.z)//String(describing:myNode.parent!.position.z)
                var pos = position1x + " " + position1y + " " +  position1z

I already tried it with this example

guard let front = sceneView.pointOfView?.simdWorldFront else {return}
let horazontalRight = cross(front, simd_float3(0,1,0))

// for moving right
node1.position +=  SCNVector3(horazontalRight *  0.01)

but it still moves the node in one direction. What am I doing wrong?

tamaramaria
  • 173
  • 1
  • 4
  • 17

0 Answers0