juanmajr93 Posted March 6, 2017 Share Posted March 6, 2017 Hi all, do you know anyway to render only the models that are near of camera (I would define a radius and I can only see the models inside this area) is it possible? Thanks! Quote Link to comment Share on other sites More sharing options...
Temechon Posted March 6, 2017 Share Posted March 6, 2017 Hi, There is nothing implemented in the framework. But it's easy to do it! For each frame, do : For all meshes, do : Compute distance between camera and the current mesh if the distance is > MAX_DISTANCE, do : mesh.setEnabled(false); Else, do : mesh.setEnabled(true); "For each frame' = scene.registerBeforeRender() "For all emshes" = scene.meshes "Compute Distance" = BABYLON.Vector3.DistanceSquared(camera.position, mesh.position) Good luck Dad72 1 Quote Link to comment Share on other sites More sharing options...
Raitch Posted March 6, 2017 Share Posted March 6, 2017 Sound like you want to use this: https://doc.babylonjs.com/tutorials/how_to_use_lod Examples if you want `mesh` to not be rendered after 50 units: `mesh.addLODLevel(50, null);` As you see in this example you can also have more simple versions of a mesh at a longer distance: http://www.babylonjs-playground.com/#QE7KM Quote Link to comment Share on other sites More sharing options...
juanmajr93 Posted March 6, 2017 Author Share Posted March 6, 2017 @Temechon @Raitch it is well but it is not exactally that I want. I only want to show the part of scene which are near of camera but not disable all mesh unless render only the part that is nearer to me.. Quote Link to comment Share on other sites More sharing options...
Raitch Posted March 6, 2017 Share Posted March 6, 2017 It sounds like we're talking about the same thing. My solution does't disable meshes. It only checks if it should be rendered depending on camera distance. Apart from that Babylon JS often doesn't render meshes behind the camera to save process power, so that part is already optimized. Perhaps you mean like a Silent Hill fog effect or how would you wish the distance to be visually shortened? Quote Link to comment Share on other sites More sharing options...
juanmajr93 Posted March 6, 2017 Author Share Posted March 6, 2017 yes just it! @Raitch I have to short the visual distance and try by this way to reduce the effort to render all models of my scene (frustum planes) Quote Link to comment Share on other sites More sharing options...
Raitch Posted March 6, 2017 Share Posted March 6, 2017 I would suggest that you try a combination of scene fog: https://doc.babylonjs.com/tutorials/environment and LOD as I linked above. The fog doesn't exclude meshes from being rendered, but you can set for example: scene.fogMode = BABYLON.Scene.FOGMODE_LINEAR; scene.fogColor = new BABYLON.Color3(0.9, 0.9, 0.85); scene.fogStart = 20.0; scene.fogEnd = 25.0; And on all relevant meshes run: `mesh.addLODLevel(30, null);` And on active camera set `camera.maxZ = 30;` Hiding the meshes wouldn't be noticed since the fog ends before their condition is met. Quote Link to comment Share on other sites More sharing options...
inteja Posted March 6, 2017 Share Posted March 6, 2017 Camera far clipping plane i.e. maxZ? Quote Link to comment Share on other sites More sharing options...
Raitch Posted March 6, 2017 Share Posted March 6, 2017 I doubt a plane mesh would take much to render the entire of it? If it's on a flat surface I guess you would have a plane as big as the fog ends, move it under your character and position the plane's texture with .uOffset and .vOffset, if I follow you correct. Maybe even have different planes next to each other with LOD if you have giant textures. I could very well be misunderstanding your question now. Okay, you can use fog and `camera.maxZ = 30;` instead of LOD on all meshes. I did not know that. 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.