sayan751 Posted September 26, 2015 Share Posted September 26, 2015 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 26, 2015 Share Posted September 26, 2015 Hello you did well but to control the camera with inertia, you have to change camera.cameraDirection: camera.cameraDirection.addInPlace(new Vec3(0, 0, -0.05)); sayan751 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.