Hagop Posted November 23, 2015 Share Posted November 23, 2015 HiI have applied a freecamera to my project.camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(-40, cameraHeight,-132), scene);I have applied gravity to it so that it won't flyie: camera.applyGravity = true;I have given it a constant height (cameraHeight) scene.registerBeforeRender(function () { scene.activeCamera.position.y = cameraHeight;}); Now the problem is that when I move the mouse up and down along the Y axis the camera rotates (in essence on the x-axis). So the camera is elevated and it's like flying.I have checked the ESPILIT demo and it's the same problem (Espilit.babylon has camera gravity enabled). So is there a command which limits the rotation of the free camera up and down (or left and right) ?If I need to calculate the rotation in registerBeforeRender then my 2nd question, can I stop a camera? Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 23, 2015 Share Posted November 23, 2015 Tried something like that already?scene.registerBeforeRender(function () { camera.rotation.x = 0;})http://www.babylonjs-playground.com/#E0QUF Buzul 1 Quote Link to comment Share on other sites More sharing options...
Hagop Posted November 23, 2015 Author Share Posted November 23, 2015 iiceman: this disables rotation completely. Any idea or command how to limit it? Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 23, 2015 Share Posted November 23, 2015 On the playground example I can still rotate the camera to the left and to the right... what do you mean with "disabled completely"? like only look a bit up and a bit down? Like that http://www.babylonjs-playground.com/#E0QUF#1 ? Quote Link to comment Share on other sites More sharing options...
Buzul Posted September 13, 2018 Share Posted September 13, 2018 On 11/23/2015 at 11:54 AM, iiceman said: Tried something like that already? scene.registerBeforeRender(function () { camera.rotation.x = 0;}) http://www.babylonjs-playground.com/#E0QUF @iiceman you are the legend .. Thanks for this old post... iiceman 1 Quote Link to comment Share on other sites More sharing options...
Mark Bufton Posted October 6, 2018 Share Posted October 6, 2018 I use a similar thing to limit the positions of drag drop meshes (called within the onPointerMove) with a limit function function limit(mesh,xMin,xMax,yMin,yMax,zMin,zMax){ if (mesh.position.x < xMin){ mesh.position.x = xMin; } //Repeat for all arguments } With a little tweaking to refer to the camera and rotations and calling it in the registerBeforeRender, I'm sure you'd be able to limit the camera's rotation to anything you like. 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.