<p>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:</p>

<pre><code>if vertex.z&gt;n {
vertex.hide= True
}
</code></pre>

<p>I have 2 questions:</p>

<ol>
<li>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?  </li>
<li>Maybe that's a better way? You must consider that to compute a new<br>
geometry and rendering it takes like 10 seconds, so I would<br>
definitely avoid creating a new "cut" geometry every time.</li>
</ol>

<p>Sorry for my poor English and thanks.</p>

CC BY-SA 4.0
2019-03-25T14:45:18.323Z
Why don't you use something like a frustrum? https://threejs.org/docs/#api/en/math/Frustum
Reynolds
CC BY-SA 4.0
2019-04-01T14:20:35.080Z
@Reynolds That's could be interesting, do you have any idea about how to manipulate the camera frustum in that way?
Nicolò Monica
<glsl><three.js>
How to hide a part of a geometry dynamically using a shader in three.js
Nicolò Monica
# How to hide a part of a geometry dynamically using a shader in three.js

(Asked by: username_0 on 2019-03-25)

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.

**Tags:** glsl, three.js

> **Comments:**
> **username_1**: Why don't you use something like a frustrum? https://threejs.org/docs/#api/en/math/Frustum  
> **username_0**: @username_1 That's could be interesting, do you have any idea about how to manipulate the camera frustum in that way?  

---

## 0 answers

