lhx880619 Posted June 5, 2017 Share Posted June 5, 2017 i just had a problem to calculate the camera position to fit all kinds of size of meshes. this pg make the mesh in the center of the screen (you can change the ground size), but not working on mobile devices. don't know why. https://www.babylonjs-playground.com/#P6JAWE Quote Link to comment Share on other sites More sharing options...
lhx880619 Posted June 5, 2017 Author Share Posted June 5, 2017 @JohnK sorry to bother you again, would you pls give me some advise about this problem? Quote Link to comment Share on other sites More sharing options...
max123 Posted June 5, 2017 Share Posted June 5, 2017 this should get you started: Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 5, 2017 Share Posted June 5, 2017 3 hours ago, lhx880619 said: @JohnK sorry to bother you again, would you pls give me some advise about this problem? Sorry but this is something I have never dealt with and also on my laptop, tablet and mobile the mesh is in the centre, so no problem!. On this occasion I can be of no help. Quote Link to comment Share on other sites More sharing options...
lhx880619 Posted June 5, 2017 Author Share Posted June 5, 2017 @JohnK yes, the mesh is in the center, but my purpose is to see the whole mesh. on my mobile phone, you can't see the whole mesh. but pc you can see the whole mesh. so i think the position.y of camera is something related to the fov of the camera? to see the whole mesh from top, i shoud get the max size of x,z and camera.y=max/ tan(fov/2) not this but should be like this Quote Link to comment Share on other sites More sharing options...
jerome Posted June 5, 2017 Share Posted June 5, 2017 With a default perspective camera, the projection is computed this way y' = y / tan(fov /2) x' = x / (tan (fov / 2) * aspectRatio) you can get the aspectRatio value with : engine.getAspectRatio(camera) Wingnut and brianzinn 2 Quote Link to comment Share on other sites More sharing options...
lhx880619 Posted June 5, 2017 Author Share Posted June 5, 2017 @jerome so this issue is related to the aspectRatio ha, thank you so much, problem solved. for those who got the same problem, pls see this https://www.babylonjs-playground.com/#P6JAWE#2 works good on both pc and mobile. the key is to take aspectRatio into consideration. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 5, 2017 Share Posted June 5, 2017 glad to help 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.