This can be reproduced using the default Xcode 3D game template (SpaceShip).
Remove the runAction line that rotates the ship in the GameViewController.
Add this line. The ship correctly faces away from the camera. Note the very small x component in the at: parameter.
ship.look(at: SCNVector3(0.001, 0, -100.0), up: SCNVector3(0, 1, 0), localFront: SCNVector3(0, 0, 1)) // Works! Ship faces away from camera.
However, it the x component of the at: parameter is exactly zero, the ship's orientation does not change. The ship continues to face the camera instead of facing away from it.
ship.look(at: SCNVector3(0, 0, -100.0), up: SCNVector3(0, 1, 0), localFront: SCNVector3(0, 0, 1)) // DOES NOT work
Seeing the same problem with simdLook()
For starters, if you show the world origin
sceneView.debugOptions = ARSCNDebugOptions.showWorldOrigin]
, you will see that thex
andy
axis are actually opposite to what they would normally be, i.e.x
is nowy
andy
is nowx
.Second, you are changing the
x
axis and notz
axis. If you want the spaceship to look away or at you, that runs along thez
axis. Negative(-) z will look at you where Positive(+)z will look away from you. Trying just changing the-100
to+100
.