Jump to content

Meshes visible to camera?


d13
 Share

Recommended Posts

Hi Everyone!

Is there some way to get a list of all the meshes within the field of view of the active camera?

The reason I ask is I'm using CSS labels on a <div> layer above the canvas for some of my meshes and don't want to render those labels if the mesh is behind the camera

I tried the code suggested in this link: 

 

 

 

I'm using it like this:

var frustumPlanes = BABYLON.Frustum.GetPlanes(scene.activeCamera.getTransformMatrix());
      if (!planet.isInFrustum(frustumPlanes)) {
        label.style.visibility = "hidden";
      } else {
        label.style.visibility = "visible";
      }

(`planet` is the name of the mesh)

This gives me the error message: "scene.activeCamera.getTransformMatrix is not a function"

Can anyone suggest what I might be doing wrong?

Thanks!!

 

Link to comment
Share on other sites

Actually the console said everything :)

camera does not have a getTransformMatrix function

The scene did in the other hand so this code should work:

var frustumPlanes = BABYLON.Frustum.GetPlanes(scene.getTransformMatrix());
      if (!planet.isInFrustum(frustumPlanes)) {
        label.style.visibility = "hidden";
      } else {
        label.style.visibility = "visible";
      }

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...