Wednesday, 25 July 2018

SceneKit unproject a point gives weird result

First, I project a specific point in the scene.

SCNVector3 topLeft = SCNVector3Make(
    -50,
    -50,
    -UIScreen.mainScreen.bounds.size.width);
SCNVector3 projectedPoint = [self.sceneView projectPoint:topLeft];

When I print the value I get an expected location on screen.

(-50 -50 -667) --> (309 212 1)

But when I unproject this, basically looking for a reverse operation.

SCNVector3 point = SCNVector3Make(309, 212, 1);
SCNVector3 unprojectedPoint = [self.sceneView unprojectPoint:point];

I get something very different.

(309, 212, 1) --> (-7.544 -7.544 -100)

What am I missing/doing wrong?



from SceneKit unproject a point gives weird result

No comments:

Post a Comment