CorayThan Posted October 30, 2018 Share Posted October 30, 2018 Is there a simple way to check if a mesh is in the frustum and not hidden by other meshes? It seems pretty easy to check if the camera is aimed at the mesh in general: scene.isActiveMesh(mesh) But I want to check if the mesh is not hidden by other meshes. I'm creating a 3-D maze and need to move/lock the camera temporarily when certain objects hidden in the maze come into view. If I have to, I can determine a geometric area where if the free camera is in that area and the mesh is active it is visible, but I'd prefer to do it an easier / better way if possible. Quote Link to comment Share on other sites More sharing options...
ssaket Posted October 31, 2018 Share Posted October 31, 2018 Hi and Welcome ! Yeah, there are two methods (https://doc.babylonjs.com/api/classes/babylon.camera#isinfrustum) and (https://doc.babylonjs.com/api/classes/babylon.camera#iscompletelyinfrustum) you'll find them in Mesh/Camera class, Regarding determining the geometric area you can use this as reference - https://www.babylonjs-playground.com/#1BDA0J#0 Quote Link to comment Share on other sites More sharing options...
CorayThan Posted November 28, 2018 Author Share Posted November 28, 2018 In case anyone else comes across this, what I was looking for was to use ray casting and check what the ray from the camera to the mesh hits: Ray.CreateNewFromTo(cameraPosition, meshPosition) const picked = scene.pickWithRay(ray) return picked.hit trevordev 1 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.