Jump to content

Moving FreeCamera in z axis


sayan751
 Share

Recommended Posts

Hi,

 

I have a requirement to move a free camera in z axis. As I have not found any out-of-the box key mapping for that, I tried to write my own as shown below.

BABYLON.FreeCamera.keysUpz = [];BABYLON.FreeCamera.keysDownz = [];..........    window.addEventListener("keydown", function(event) {        var keyCode = event.keyCode;        if (camera.keysUpz.indexOf(keyCode) > -1) {            console.log("Going up");            //camera.position.z += 0.05;            //camera.position.addInPlace(new Vec3(0, 0, 0.05));        }        else if (camera.keysDownz.indexOf(keyCode) > -1) {            console.log("Going down");            //camera.position.z -= 0.05;            //camera.position.addInPlace(new Vec3(0, 0, -0.05));        }    });

I have tried two ways to do that: 1. using position.z and 2. position.addInPlace(new Vec3(0, 0, z))

 

However, the translation of the camera is not smooth as in default movement of the camera.

 

What I can do to achieve the same?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...