There are no articles on adding and removing model vertices?

I want to achieve one:

  1. Create a pipeline model

  2. When the pipe model is inserted into any part of the terrain, the inserted center area deletes the corresponding vertex so that the inserted center is empty and not rendered (like the mouth of a tunnel).

  3. Currently I use pick() to get terrain pickResult.pickedMesh?.getIndices() Vertex index sumpickResult.pickedMesh?.getFacetLocalPositions() Vertex XYZ

  4. But then I don’t know how to filter the pipe into the central area of the terrain and operate on the vertex of the central area

This can help with manipulating vertices Babylon.js docs and most of the articles around in the doc are about creating custom meshes.

Consider using CSG to create your model. Create a mesh of the pipe that will be outer thickness. Then an inner mesh that represents the center to be removed.

const pipeCSG = BABYLON.CSG.FromMesh(outer);
const centerCSG = BABYLON.CSG.FromMesh(center);
pipeCSG.subtractInPlace(centerCSG);
var pipe = pipeCSG.toMesh("pipe");
1 Like