# PointsMaterial. How Do I Prevent Vanishing Points On Zoom Out?

**URL:** <https://discourse.threejs.org/t/pointsmaterial-how-do-i-prevent-vanishing-points-on-zoom-out/9776>\
**Category:** Questions\
**Tags:** pointsmaterial\
**Created:** [September 20, 2019, 8:36pm UTC](https://discourse.threejs.org/t/pointsmaterial-how-do-i-prevent-vanishing-points-on-zoom-out/9776 "2019-09-20T20:36:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dugla](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dugla/32/4044_2.png) [@dugla](https://discourse.threejs.org/u/dugla)\
**Post date:** [September 20, 2019, 8:36pm UTC](https://discourse.threejs.org/t/pointsmaterial-how-do-i-prevent-vanishing-points-on-zoom-out/9776/1 "2019-09-20T20:36:06Z")

</div>

I am using `PointsMaterial` to create an interactive “point cloud” from a dataset. Tens of thounds of points fill a large space. I have enabled size attenuation. As a result when dollying the camera out from the point clusters they progressively vanish as their screen space size falls below one pixel.

What strategy can I use to prevent disappearing points. One idea I have is to somehow clamp the minimum size of the points but I am not sure how to go about this.

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [September 20, 2019, 8:45pm UTC](https://discourse.threejs.org/t/pointsmaterial-how-do-i-prevent-vanishing-points-on-zoom-out/9776/2 "2019-09-20T20:45:15Z")

</div>

Hi!  
Are you sure that the vanishing points are not further than the far plane of the camera?

---

<div class="post-metadata">

**Author:** ![dugla](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dugla/32/4044_2.png) [@dugla](https://discourse.threejs.org/u/dugla)\
**Post date:** [September 20, 2019, 8:47pm UTC](https://discourse.threejs.org/t/pointsmaterial-how-do-i-prevent-vanishing-points-on-zoom-out/9776/3 "2019-09-20T20:47:41Z")

</div>

Yes. I have confirmed this by increasing the size of the points. The points remain visible for a longer time as I dolly out. I have also increased the far clip plane a significant amount.

---

<div class="post-metadata">

**Author:** ![stopyransky](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/stopyransky/32/3526_2.png) [@stopyransky](https://discourse.threejs.org/u/stopyransky)\
**Post date:** [April 18, 2022, 8:45pm UTC](https://discourse.threejs.org/t/pointsmaterial-how-do-i-prevent-vanishing-points-on-zoom-out/9776/4 "2022-04-18T20:45:28Z")

</div>

You could clamp the gl\_PointSize of your particles.  
For this you would need to create custom shader as far as i know.  
In the shader something like this worked for me:

```javascript
    gl_PointSize = aSize;
    gl_PointSize *= ( scale / - mvPosition.z );
    gl_PointSize = clamp(gl_PointSize, minSize, maxSize);

```

scale = canvas.height \* 0.5;  
mvPosition = modelViewMatrix \* vec4(position, 1.0);

I think the default implementation in PointsMaterial could be improved with above too…  
for example the scale value depending on canvas height is a bit dodgy - shouldn’t it be min(canvas.height, canvas.width) ? For mobile it would make a difference i guess. slight off-topic though.
