Detecting objects which can camera see

hello everyone, i have an issue here i want to detect which geometries camera can see

for example

i want to detect all this geometries which can be seen by camera and make behind part visible = false

how can i achieve that? thank you.

isn’t this done automatically for you by threejs? that’s why materials have the side prop which defaults to frontside. backside (the behind-side) is invisble/not rendered.

Does it really need to consist of such big amount of elements?

I am aware of that BUT if i manually make half of it visible false it has better performance so i am looking something new.

Unfortunately yes, its a project they are demanding To do like this, but there is huge performance drop because If i load alL geometry there are like 5400 geometry + 5400 edge geometry so i am looking solutions, i use bufferGeometry basic materials no lights i am making scene as light possible but nothing comes out.

Instancing, as an option? Using Instancing for EdgeGeometry / LineSegments - #7 by prisoner849

All objects in my scene have different size color depth and etc… will indtancedMesh still work? Also is there any other approach for edge geometry? Cuz it makes scene very heavy

Basically, all your objects are distorted boxes, so you can distort them individually, passing desired parameters via instanced buffer attributes.
And instead of edge lines, you can try to use this approach: How to update color values when using a shader? - #5 by prisoner849

1 Like

Thank you very much!

To tell what to do is always easier, than to tell and to show.
Here is an option with all the things I mentioned in my previous post.



Again thank you very much! I tried it and it works amazing!

@webIka You’re welcome :slight_smile: :beers:

Question about this thread : could each of these elements have UserData attribute values ?

Say for example two attributes : M-index and N-index. Could we assign to each element of the instancedBuffer Geometry different values to M-index and N-index (at the user discretion) ? If so, how to achieve this. If not, what are other alternatives ?

Great Example !!

@Nemines do you want to process those indices in shaders somehow?

I’m not sure I understand what do you mean by that. One application of what I mean by that is to be able to filter out all these elements by UserData attributes (N-index and M-index for example).

The user can also color code these elements according to the UserData attributes values (for example low values would be blue and high values would be red) as per turbo color scheme for example…

I don’t know if you understand what I mean ?