Jump to content

Intersect and Frumstrum


TomaszFurca
 Share

Recommended Posts

Hi, in my project i have a lot modules which must register anonymous function in sceneAfterRender. Some of them uses intersectsMesh. What you think about check mesh is active, before check intersects?

For example checking player collisions, with only colliders, which are visible in camera:

for (var i = 0; i < colliders.length; i++) {
 var mesh = game.sceneManager.environment.colliders[i];
 if(scene.isActiveMesh(mesh)) {
  if (this.mesh.intersectsMesh(sceneMesh, false)) {
   ...
  }
 }
}

 

Tomasz Furca

Link to comment
Share on other sites

One thing about mesh level beforeRender & afterRender functions:  they themselves are only called if the mesh they are attached to are active that frame.  If you think there is no likely hood that a mesh that is active could intersect a mesh that was not, then should work.

BTW, a scene level beforeRender & afterRender always runs.

Link to comment
Share on other sites

also forgot to mention, I am pretty sure if you have multiple cameras (VR), mesh level beforeRender & afterRender get called multiple times.  You might put in checking for the renderID as well, if you plan such a deployment.  This is one of the reasons for a QI.Mesh that I use a scene level beforeRender, even though I have one for every mesh.

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...