Armin Masoomi
Armin Masoomi

Reputation: 135

Three.js Perspective Camera X axis is flipped

I have a scene with two camera, one is Orthographic and the other is a perspective, when orthographic camera is active everything looks normal, but perspective camera shows the scene X axis upside down, is there any way to fix it? my two cameras are added to the scene normally:

camera = new THREE.PerspectiveCamera(50,4 / 3,0.1,10000);
cameraO = new THREE.OrthographicCamera(-2, 2, -2, 2, 1, 100);

here is an example : https://jsfiddle.net/g7juxm2q/12/ switch cameras by pressing "P" and "O".

Upvotes: 3

Views: 977

Answers (1)

M -
M -

Reputation: 28502

The problem is not that the perspective camera has its axis flipped. The problem is that you're declaring your orthographic camera with a negative top and positive bottom parameters. Top is typically +y and bottom should be -y, as outlined in the OrthoCam docs

// Docs:
OrthographicCamera( left, right, top, bottom, near, far );

// Your implementation has top as -2, bottom as +2
THREE.OrthographicCamera(-2, 2, -2, 2, 1, 100);

Upvotes: 6

Related Questions