2

I have a question and hope that you can help me.

We are trying to display a 3D point cloud with about 200K points like the one below, with a colorbar.

enter image description here

When the user zooms in we would like to update the colorbar to match the new min/max of the points still visible to get more contrast on the details important to the user.

Therefore we need to find the new min/max of the points still visible and we need to assign the new color to the points.

If we just iterate through the array in JS and assign the colors manually this feels quite laggy. Do you have an idea on how this could work, maybe using three.js functions that run on the GPU.

In short:

  • How to get the points still visible, is there an event?
  • Fastest way to get the min / max of the points visible after user interaction?
  • How to adjust the colors of the points without iterating in JS?
Joe
  • 6,758
  • 2
  • 26
  • 47

1 Answers1

2

How to get the points still visible, is there an event?

No, there isn't. You have to iterate through all points, transform each one into world space and check whether the point lies within the camera's view frustum or not.

Fastest way to get the min / max of the points visible after user interaction?

You have to iterate through all points and then check for min/max values.

How to adjust the colors of the points without iterating in JS?

If you know the min/max values, you can pass them into the shaders as uniforms and use them to update the vertex/point color.

Mugen87
  • 28,829
  • 4
  • 27
  • 50
  • But it would be possible using the shader? see [here](https://stackoverflow.com/questions/46228275/how-to-change-the-colors-in-this-three-js-demo) or [here](https://discourse.threejs.org/t/how-to-update-color-values-when-using-a-shader/25686/2) or [here](https://discourse.threejs.org/t/give-specific-color-to-texture-in-fragment-shader/13774/9) ? – Joe Sep 14 '22 at 13:45
  • When you want to process min/max values on the GPU then yes, you need a custom shader. You can create one from scratch with `THREE.ShaderMaterial` or you enhance a built-in material via `Material.onBeforeCompile()`. – Mugen87 Sep 14 '22 at 17:56
  • And assigning the colors could also be done using the shader, right? But is there a way to get the visible points after zoom using a shader? – Joe Sep 14 '22 at 18:08
  • When yo mean with assigning the computation of the color value then yes. I'm not aware of getting the visible points though. – Mugen87 Sep 14 '22 at 21:19