cnr-isti-vclab / nexus

Nexus is a c++/javascript library for creation and visualization of a batched multiresolution mesh
GNU General Public License v3.0
213 stars 86 forks source link

Raycaster often doesn't return nearest intersection point #165

Open benedikt7 opened 4 months ago

benedikt7 commented 4 months ago

Hello!

First of all, thank you very much for this extremely exciting project. Very cool implementation. Thank you for making your results available!

I work with large CAD models of industrial machines, which sometimes have a very complex interior with components. Loading and rendering work perfectly and very efficiently. The problem: The raycaster unfortunately works very "faulty". Intersections often only include points on parts that are in the background, while the actually selected part of the model is not part of the result set. Especially with parts inside the machine, the raycaster usually provides intersection points that do not lie in the foreground but rather concern parts further "back" in the machine.

Could this possibly be because the raycaster is still working with a simplified version of the model where detailed geometry is not yet taken into account?

I would greatly appreciate input and ideas for improvement!

ponchio commented 4 months ago

Hi, yes, the code for raycasting is using an approximate version. For large models raycasting would be pretty expensive, as it is done in Javascript, in the CPU. For 3d models like statues or coming from photogrammetry this is usually not a huge deal, but indeed for cad models it can be.

Two improvements are possible:

1) use higher resolution, some configurable intermediate level of geometry, at the price of processing more triangles and using more ram.

2) use a different strategy: make another rendering with a very small viewport around the mouse position and fetch the pixel under the mouse (at a price of an additional rendering and a fetch request, both potentially expensive).

I could provide the code for both methods (i am currently pretty busy...)

On Wed, Feb 14, 2024 at 1:19 PM benedikt7 @.***> wrote:

Hello!

First of all, thank you very much for this extremely exciting project. Very cool implementation. Thank you for making your results available!

I work with large CAD models of industrial machines, which sometimes have a very complex interior with components. Loading and rendering work perfectly and very efficiently. The problem: The raycaster unfortunately works very "faulty". Intersections often only include points on parts that are in the background, while the actually selected part of the model is not part of the result set. Especially with parts inside the machine, the raycaster usually provides intersection points that do not lie in the foreground but rather concern parts further "back" in the machine.

Could this possibly be because the raycaster is still working with a simplified version of the model where detailed geometry is not yet taken into account?

I would greatly appreciate input and ideas for improvement!

— Reply to this email directly, view it on GitHub https://github.com/cnr-isti-vclab/nexus/issues/165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUDV25DLWU5TEICPIHCFXTYTSTULAVCNFSM6AAAAABDIFZRC2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGEZTIMRTGE4DGNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

benedikt7 commented 4 months ago

Hi! Thanks for the input. Solution 2 sounds very suitable for my use case, as RAM on the target devices is quite limited. Do you have an approximate timeline for how long the implementation would take?

Thanks!