Flomotion Posted September 3, 2015 Share Posted September 3, 2015 Hi all, I'd like to know if anyone knows how to determine if a 3D point is out of range from the camera view. I'm making 2D labels on top of a 3D model. And it all works nice but when camera is 180 to the object, the 2D labels appear back on the canvas. I based what I'm doing on this example by Wingnut. http://playground.babylonjs.com/#1HLSBC%234 You'll see the menu's floating by if you zoom a bit closer to the red sphere and make a box float behind you. So to prevent that from happening.. my question again: I'd like to know if anyone knows how to determine if a 3D point is out of range from the camera view? :-) Floris jahanzaib 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 4, 2015 Share Posted September 4, 2015 Hi Floris, I believe Frustum inspection can help in your case. It will inspect if an object is in the camera's view.The only catch is - it will return true also when an object is hidden behind another object. To use it, get the frustum planes of your camera:var frustumPlanes = BABYLON.Frustum.GetPlanes(scene.getTransformMatrix());and then use it to determine if part of the object is in the camera's view:if(!mesh.isInFrustum(frustumPlanes)) { doSomethingWithTheMesh(mesh);} You could also get the array of active meshes from the scene and use it - Simply put, active meshes can be seen as meshes in the camera's view. To Get it:var smartActiveMeshesArray = scene.getActiveMeshes(); Or check if a mesh is active:var active = scene.isActiveMesh(mesh); I hope it helps! jahanzaib 1 Quote Link to comment Share on other sites More sharing options...
Flomotion Posted September 4, 2015 Author Share Posted September 4, 2015 Thanks for your reply. It certainly helps!I'd only have to add some small geometry in my scene at the desired places to solve the issue. Floris jahanzaib 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.