ibGoge Posted January 29, 2018 Share Posted January 29, 2018 Hi, I have an ECS engine and want to keep the camera, input, and entities separate. In this case the GameCamera is a system that is assigned an entity to read it's position and direction from and update the BabylonJS camera with. I already have a working Controller system that attaches to the scene's `onKeyboardObservable` and I am going to use the `onPointerObservable` for mouse movement. However I don't see how to set the `Camera` view direction, only it's position. Is there no simple way to either specify a normal vector3 for direction or a rotation radian and an up vector? I don't see anything in the documentation or in the source, what am I missing? Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 29, 2018 Share Posted January 29, 2018 Hello and welcome! you can use camera.setTarget() The target can be computed like this: camera.position + direction Cheers! Quote Link to comment Share on other sites More sharing options...
ibGoge Posted January 29, 2018 Author Share Posted January 29, 2018 Thank you! I'll give this a shot on the commute. I knew I must have been missing something GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
ibGoge Posted January 31, 2018 Author Share Posted January 31, 2018 Thanks for the help, the TargetCamera and setTarget did the trick but I am running into a new issue. My Camera position is outside of a box, however when I turn the camera around, the camera cuts through the box and due to back culling everything disappears. I made a room by placing 1x1x1 cubes in a grid, 5x5 with the middle 2x2 open space. If I move the camera close to a box or into the corners of the room the camera cuts through the boxes. But the position of the camera is still outside of the box space. Here is a gif of the effect: https://imgur.com/Meovl9F How can I determine if the viewport? is going to cut into a box and keep myself from getting that close? Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 31, 2018 Share Posted January 31, 2018 You can reduce the near plane distance by setting camera.minZ = 0.1 (or less depending on your unit) 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.