user3112634
user3112634

Reputation: 693

Flip camera upside down three.js

I am using PerspectiveCamera and OrbitControls and i am wondering if i could completely flip the camera so it’s basically upside down (making the scene apear upside down)? it would also be handy to know how to change it back again to the right way up! thanks in advance

Upvotes: 1

Views: 1659

Answers (1)

jscastro
jscastro

Reputation: 3780

EDIT: FROM @WestLangley suggestion

You only have to turn the camera upside down with this camera.up.set(0, -1, 0); after your camera definition.

    camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
    camera.position.set(0, 0, 1000);
    camera.up.set(0, -1, 0);

enter image description here

Just set it again to 0 whenever you want to restore to the regular position, so if you are thinking on flipping it based on any user interaction, I'd recommend to use a variable.

//somewhere in your code
let flipped = true; //or false depending any user interaction assigned
camera.up.set(0, (flipped ? -1: 0), 0);

Upvotes: 2

Related Questions