Three.js: way to change the up axis?

16,442

You can set the camera up vector like so:

camera.up.set( 0, 0, 1 );

Then when you call camera.lookAt( point ), it will work as you expect.

Edit: Updated to three.js r.68

Share:
16,442

Related videos on Youtube

Eric
Author by

Eric

Updated on July 26, 2022

Comments

  • Eric
    Eric almost 2 years

    I see that the ColladaLoader has a way to set the upAxis to 'Z' ... is there a way to do that in Three.js proper so that the camera's up axis is Z?

    Thanks!

  • gimg1
    gimg1 almost 11 years
    Is there any workaround available so that OrbitControls will accept a change in up?
  • WestLangley
    WestLangley almost 11 years
    Not that I am aware of. You would have to rewrite it.
  • gimg1
    gimg1 almost 11 years
    So I hacked up the OrbitControls.js file so that it now works if you set z as up. I can probably make it even better so that it changes based on what up is set. Would that be helpful?
  • WestLangley
    WestLangley almost 11 years
    You would have to file a pull request at the three.js github site to find out.
  • z0r
    z0r over 10 years
    TrackballControls seem to work well with z as up out of the box in r62. threejs.org/examples/misc_controls_trackball.html
  • user3405291
    user3405291 over 2 years
    @z0r I tested TrackballControls. As far as I tested, it doesn't work good with camera.up.set( 0, 0, 1 )