ggg Posted March 6, 2017 Share Posted March 6, 2017 Could anyone please help me by advising on how do we set the camera view angle to the cavas using babylonjs? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 6, 2017 Share Posted March 6, 2017 Hi ggg! http://www.babylonjs-playground.com/#10AS2Y#1 Here is a playground with various freeCamera aiming. Is that what you mean by "view angle"? Or do you mean "field of view"? (camera.fov and .fovMode) Anyway, line 7 sets the camera initial position, and line 10 is one way to aim the camera. Lines 33-34 is another way. Activate lines 38-39 for aiming-by-math. I hope I am on-topic. Perhaps we are talking about the "view matrix"? The Camera base class has some interesting properties and methods. FreeCameras inherit them all, plus some more from targetCamera. FreeCameras are great little cameras... esp considering they are free! (ar ar ar) Know how to use your browser's object inspector? Do console.log(camera) and then click on the word 'object'. The object inspector should open. Then you can view and even SET some values on the freeCamera... LIVE. Viewing cameras, lights, mesh, ANY JS object... with an object inspector... is an excellent way to learn things FAST. I love 'em. console.log(object)... RUN... then go to console and click on it. Object sniffing is FUN! Hope this helps. Quote Link to comment Share on other sites More sharing options...
ggg Posted March 6, 2017 Author Share Posted March 6, 2017 54 minutes ago, Wingnut said: Hi ggg! http://www.babylonjs-playground.com/#10AS2Y#1 Here is a playground with various freeCamera aiming. Is that what you mean by "view angle"? Or do you mean "field of view"? (camera.fov and .fovMode) Anyway, line 7 sets the camera initial position, and line 10 is one way to aim the camera. Lines 33-34 is another way. Activate lines 38-39 for aiming-by-math. I hope I am on-topic. Perhaps we are talking about the "view matrix"? The Camera base class has some interesting properties and methods. FreeCameras inherit them all, plus some more from targetCamera. FreeCameras are great little cameras... esp considering they are free! (ar ar ar) Know how to use your browser's object inspector? Do console.log(camera) and then click on the word 'object'. The object inspector should open. Then you can view and even SET some values on the freeCamera... LIVE. Viewing cameras, lights, mesh, ANY JS object... with an object inspector... is an excellent way to learn things FAST. I love 'em. console.log(object)... RUN... then go to console and click on it. Object sniffing is FUN! Hope this helps. Thanks for the kind reply. Unfortunately, the mentioned PG was not of good help in my needs. Here is my PG http://www.babylonjs-playground.com/#TA6A7#2 in which I want to set the default camera angle so that, the lines are visible in 3D. Currently it is viewd in 2D. We can see in 3D only when we rotate the canvas. But I want the canvas to be seen in some other camera angle so that, the lines are viewed in 3D. Could you please help? Quote Link to comment Share on other sites More sharing options...
JohnK Posted March 6, 2017 Share Posted March 6, 2017 Line 12 in your PG sets the camera angles More about arcRotateCamera here http://babylonjsguide.github.io/basics/Cameras#arc-rotate-camera GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
ggg Posted March 7, 2017 Author Share Posted March 7, 2017 16 hours ago, JohnK said: Line 12 in your PG sets the camera angles More about arcRotateCamera here http://babylonjsguide.github.io/basics/Cameras#arc-rotate-camera Thanks for the quick guide JohnK. Would you also please advice me how do I set the camera distance? Now, I could set the camera angle. But When the lines draw, I needed to scroll my mouse up/down to see the lines in full view. If I could set the camera view distance, that would be really great. Could you advice on this please? Quote Link to comment Share on other sites More sharing options...
JohnK Posted March 7, 2017 Share Posted March 7, 2017 If you read tutorial on arcRotateCamera, as given in my link, you will see distance is radius, the second parameter. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
ggg Posted March 8, 2017 Author Share Posted March 8, 2017 15 hours ago, JohnK said: If you read tutorial on arcRotateCamera, as given in my link, you will see distance is radius, the second parameter. Thanks for the advice JohnK. It was really helpful and I was able achieve my idea to reflect on web page. Thanks again! 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.