Jump to content

Hide objects by max view range


reddozen
 Share

Recommended Posts

Is there an existing way to do this without looping through every object in the scene and doing additional expensive distance calculations?

 

If not, could a new variable be added to mesh for "max view range", default 0 (unlimited), and with the same distance check loop that the LOD engine goes through, set these meshes to visible / invisible based on this range if not 0?

Link to comment
Share on other sites

 

The LOD systems allows you to do this by calling:

var viewDistance = 100;mesh.addLODLevel(viewDistance, null);

 

Interesting, but how can this be incorporated with the auto LOD?

 

For example:

I have my parent part that  assign my auto LOD to.

I have a couple instances that i need varying view ranges on for scene optimizations.

I cannot set a generalized null distance on the parent to feed down to the instances because it's situational.

Link to comment
Share on other sites

The automatic LOD is not designed for it (not yet)It would add another parameter to hide the object along a certain distance.
 
for exemple:

 

add: show: false => hide meshe

newMeshes[0].simplify([{distance:250, quality:0, show: false}]) //Default show: true.

What do you think Raanan ?

Link to comment
Share on other sites

This wouldn't fix my specific situation though dad72. Have to remember that I'm loking for a solution at the mesh level. Be that a parent, clone, instance, whatever. LODs are assigned at the parent level, so my max view range setting would then be only at the parent level.

 

This new variable would be in there with the position xyz, rotation xyz, and scale xyz variables assigned to every mesh.

mesh.maxRange = 100;
Link to comment
Share on other sites

I haven't tested this nice suggestion of amorgan, but I think adding it to the parent mesh with a specific distance will cause all others to behave the same, as the LODs used are the same.
So setting a null at distance 200 will make all instances disappear if the camera is 200 units away from them.
Again, haven't tested, but should work :-)

Seems like it is working. making it variable is another thing (200 for one mesh, 300 for another) - http://www.babylonjs-playground.com/#2JBSNA#1

Edited by RaananW
Link to comment
Share on other sites

  • 2 years later...

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