I have a very big geometry in three.js and I want to hide a section of that geometry along an axis (for example every vertex with a Z>N must be hidden). My idea is to create a custom shader in GLSL that does something like:

if vertex.z>n {
vertex.hide= True

I have 2 questions:

  1. I have to do that in real time several times with different N values provided by the user, can I use something that "tells" to the shader the N value dynamically without creating and assign every time a new shader with just a different value?
  2. Maybe that's a better way? You must consider that to compute a new
    geometry and rendering it takes like 10 seconds, so I would
    definitely avoid creating a new "cut" geometry every time.

Sorry for my poor English and thanks.

  • $\begingroup$ Why don't you use something like a frustrum? threejs.org/docs/#api/en/math/Frustum $\endgroup$ – Reynolds Mar 25 '19 at 14:45
  • $\begingroup$ @Reynolds That's could be interesting, do you have any idea about how to manipulate the camera frustum in that way? $\endgroup$ – Nicolò Monica Apr 1 '19 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.