Removing / Editing / Erasing a line mesh created using a LineSystem

How to erase or remove a created line’s indices corresponding to mouse pointer intersection with that line?

Hello and welcome!

can you be more precise? The best way to get a fast answer is to provide a repro of your problem using our playground

Welcome @Abhinav_Pandey, unfortunately IMHO there is no easy answer to you question.

Updating any mesh using the updatable parameter only works if the number of vertices does not change. So adding or removing new points on a line means disposing of the current line and creating a new line. What you would need to do would be to maintain a data structure of points independent of the lines mesh.

As a starting point here is a PG Babylon.js Playground where you click on a line and it places a red sphere at that point. The following steps would also then be needed

  1. The point clicked on may be close to the line and a recalculation may be needed to place the point exactly on the line
  2. Find the two points the new point lies between add to data structure.
  3. Dispose of current line
  4. Draw new line based on new data points.

Of course if your lines were based on curve equations more work is necessary.

At http://cubees.github.io/ if you go to the right hand panel and select either Lathe or Extrude you will see a basic line editing system for Bezier curves using BABYLON.js although lines are restricted to 2D. Code here

Have fun. Start small. Create a playground and ask for help as needed :slightly_smiling_face:

1 Like