0
votes

So,

I have the exact position I want to place the node at. If I test things with a sphere geometry I can place spheres in the world by telling the node:

node.simdPosition = position

(I provide the "position" as an input to the function).

That successfully places the object in the world exactly where I want it to go.

What I really want to do is placing a plane:

let plane = SCNPlane(width: 0.2, height: 0.3)
plane.cornerRadius = plane.width / 10
plane.firstMaterial?.diffuse.contents = UIColor.red
plane.firstMaterial?.specular.contents = UIColor.white
let node = SCNNode(geometry: plane)

Then telling it to be placed at the "position":

node.simdPosition = position

All this works with the plane as well. What I have problems with is the angle:

I want to tell the plane's node to be placed with a given "angle" (around Y) offset to the camera. I tried this but it's not working:

node.rotation = SCNVector4Make(0, 1, 0, currentFrame.camera.eulerAngles.z - angle)

So then, the question is, how can a node be placed at a certain position and at the moment it gets placed in the world, also have a certain Y angle offset from the perpendicular to the camera?

1
this worked: node.eulerAngles = SCNVector3Make(0, cameraEulerAngles.y - Float(0.7), 0)zumzum

1 Answers

0
votes

I was using the wrong Euler angle... (z)

This made it work:

node.eulerAngles = SCNVector3Make(0, cameraEulerAngles.y - Float(0.7), 0)