Wrote this code:
target.set(position).add(direction);
up.set(0, 1, 0);
if(direction.x == 0 && direction.y == 0);{
up.set(0, 0, 1); //Ensure up is not the same direction as "direction"
}
System.out.println(up); //Bug: up is always (0, 0, 1).
viewMatrix.setToLookAt(position, target, up);
Neither direction.x and direction.y were 0, but up was still set to (0, 0, 1). What was the problem?
Answer:
[spoiler]
There’s a semi-colon right after the if()-clause. The code is basically this:
if(…);
{
up.set(0, 0, 1);
}
It’s an if-statement without a body. The curly braces are unrelated to the if-statement and don’t really do anything here.
[/spoiler]
Not sure if that was obvious to everyone else, but it sure took me some debugging to find that… .___.