surface reconstruction in javascript

Hi,
I’m visualizing a point cloud in browser to user, along with a set of controllers that by interacting with them, point cloud gets updated and visualized again in real time.
Now I want to visualize the surface instead of point cloud. It means by interaction of user, the new point cloud gets generated, its surface gets constructed and visualized in the realtime.

But seems like there’s no VTK.js implementation for surface reconstruction.

for such scenario what kind of solution you’ll make:
1-sending point cloud to server every time the user changes it interactively, then constructing surface on server using vtk in python, sending back to client and visualizing it
2-implementing a lightweight surface reconstrcution algorithm in javasctipt ( I’m not sure how convenient it is to do?) or maybe you can let me know of any libraries out there that does the surface reconstruction in js.
3-using web assembly or cross-compilataion schemes to port surface reconstruction from an existing vtk implementation to js. (I have no familiarity how to do that, but willing to learn if that’s not a real tricky job and there’s some resources how to do that)

I appreciate your solutions and ideas,
Best Regards,
Saeed

It will depend on the amount of data (number of points) and speed that you need to achieve.
Your options seems reasonable but it is hard to pick one without more knowledge of the data and/or doing some experiments.

1 Like

@Sebastien_Jourdain Well, actually it’s desirable that users can see no lags or delays while they’re interacting with the controllers that update the point cloud. for now the point cloud has points in the order of 3000 points.

Considering these setup and expectations, I’m wondering which option would be a better choice?

Best regards,
Saeed

Where are the point coordinates coming from? From a web service, from a client lidar device?

3000 points is fairly small. So it might be fine to process it all on the client side, but you will have to validate that assumption.

If you have the data remotely, I would go with a vtkweb/pvweb setup where you synch the scene with vtk.js on the client side while letting all the computation happen on the server side.

1 Like

Well, all the coordinates are calculated in the client side.
Actually, I have a few csv files containing some parameters in the form of matrices and vectors. In the beginning, these parameters are loaded into the window, and during the interaction of the user with the controllers on the page, the coordinates of point cloud gets calculated in real-time based on the parameters and the controller values changed by user, on any change (this can be really frequently).
so no data is remote and it’s all computed on the page.
for now all is going well and the real-time calculation of point cloud is really smoothly possible on the client, yet I’m not sure about the overhead of surface reconstruction after each point cloud generation.

I would try to run the surface reconstruction in a worker to see how it behave assuming you can implement it in JS or WASM.

I agree. So for running a worker thread with a surface_reconstruction functionality I need first to port surface reconstruction from C++ to WASM.
@Sebastien_Jourdain Is there a good tutorial or comprehensive example on how to do that (especifically in vtk code, like the one that I want to do)?

Not really, but this would be the best entry point.

1 Like

I agree with Sebastien concerning the link he referred to. I am currently running VTK in WASM, including dynamically creating polydata and imagedata, and the speed seems to be great. I used the link Sebastien referred to and was up and running in a relatively short time.

1 Like

The MultiCone Emscripten example is what I based my code on since it shows interaction between javascript and wasm.

1 Like