How to make 3D lasso tool

i need help with something , someone kindly guide me

now i am using stock webgl , and i decided to add three.js

the webgl i am using , allows me to import Stl or obj and draw on its surface

so what i need to do is to draw 3D lasso on its surface to select area here link of webgl i am using
please someone help me

Here is a demo I put together demonstrating how to implement a lasso tool with the three-mesh-bvh library I maintain. The code can be found in the selection.js file in example folder.

Depending on your use case performance may be good enough without an acceleration structure. Here’s a rough overview of the algorithm I used for finding the lasso selection for every triangle that intersects the lasso shape:

  1. Construct a list of screen space line segments that represent the lasso shape drawn by the user.
  2. For every triangle in the geometry check if any part is within the lasso. If it is then consider the triangle selected.

To determine whether a triangle intersects the lasso:

  1. Project the triangle vertices and edge segments into screen space.
  2. Check if any of the triangle vertices are within the lasso shape, which you can use the ray-crossing algorithm for. If any of the crossing numbers are different between the points or if any of the crossing counts are odd then the triangle intersects the lasso shape.
  3. Check if any of the triangle line segments intersect any of the lasso line segments. If they do then the triangle intersects the lasso shape.
  4. Otherwise the triangle has not been intersected.

Spatial index data structures can be used to quickly cull large sets of triangles by determining if parent bounds are entirely encapsulated by the lasso shape or do not intersect at all which can give a bit of a performance boost if needed.

5 Likes

thank you for help , may you kindly tell me how to apply it to sculptgl ? i have been trying but i am lost ,
and is there away to make selection by put dots or points on the 3D model and once they are connected they select the area ? and as well move the dots or points over the 3D models to adjust the selected area
@gkjohnson

may you kindly tell me how to apply it to sculptgl

I cannot – I’m unfamiliar with sculptgl. It doesn’t look to be based on three.js, either.

is there away to make selection by put dots or points on the 3D model and once they are connected they select the area ? and as well move the dots or points over the 3D models to adjust the selected area

Of course it’s possible to implement this but I doubt anyone already has this feature created in a ready to use way. These are complex features and it’s probably best to make head way on your own implementation and ask more specific questions if you get stuck.

1 Like