brean Posted October 27, 2018 Share Posted October 27, 2018 Hi, I am building a openstreetmap-integration to Babylon.js and I like to only load tiles that need to be shown and dispose tiles that are not visible anymore. To do that I need some way to figure out what tiles are in the view. I already found BABYLON.Vector3.Unproject which I could feed with the screen width/height divided by 2 in all directions to calculate the dimensions of the viewport in babylon coordinates. I only manage to get this working when the camera is directly in front of the screen, so I need to figure out how the distance from the camera to the screen can be used, see: http://www.babylonjs-playground.com/#ZFXWSF Can anyone tell me how I get the dimensions of the viewport at a cirtain distance in babylon coordinates? Quote Link to comment Share on other sites More sharing options...
ssaket Posted October 28, 2018 Share Posted October 28, 2018 18 hours ago, brean said: I am building a openstreetmap-integration to Babylon.js and I like to only load tiles that need to be shown and dispose tiles that are not visible anymore. Hello.. this seems like a LOD problem (https://doc.babylonjs.com/how_to/how_to_use_lod), but based on your post, you can also try isInFrustum method. Few PGs that are already available https://www.babylonjs-playground.com/#12D0ST#1, https://www.babylonjs-playground.com/#050P3M#1 EDIT: If I am not wrong, then viewport would be constant irrespective of camera's movement.. but again, I am not sure. Maybe someone from core team should be able to answer. ?? brean and NasimiAsl 2 Quote Link to comment Share on other sites More sharing options...
brean Posted October 29, 2018 Author Share Posted October 29, 2018 Hey ssaket, Yeah, that is helpful, this way I can check which tiles to dispose, thank you! But I still don't know how many tiles to load at the beginning. I could just create one tile in the middle of the screen, then add neighbouring tiles in all directions, check if they are in the frustum, if so load the map texture and then check their neighbors but maybe there is a better way to do that; get the width/height directly and calculate how many tiles to load from? Quote Link to comment Share on other sites More sharing options...
brean Posted October 29, 2018 Author Share Posted October 29, 2018 I ended up using this: https://www.babylonjs-playground.com/index.html#050P3M#11 (its using frustrum to check if tiles are visible) ssaket and GameMonetize 2 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.