Hi, I am developing an app which uses a polyline to slice a mesh into 2 pieces interactively by the user. I have managed to draw the polyline on the 3D mesh but can’t figure out how to slice it.
Say there is a polyline drawn on the mesh and around it, near the upper part. I want to change the color of the upper part (e.g. green) and then slice it out so that the mesh will split into 2 complete pieces for further processing etc.
Any help would be much appreciated, thanks a lot!
I changed the code to the following but it turns out that
- the color painted it NOT green (0x00ff00), but black instead
- it is painted everywhere on the 3D mesh, instead of the area above the green line
Here is the code
for (let i = 0; i < verticesCurve.length; i = i + 3) {
for (let j = 0; j < verticesSocket.length; j = j + 3) {
if (verticesSocket[j+1] > verticesCurve[i+1]) {
for (let idx = 0; idx < colorAttribute.count; idx++) {
colorAttribute.setXYZ(idx, color.r, color.g, color.b);
}
console.log(“processing…”, loopTimes++);
}
}
}
So finally I figured out that the failure is due to the fact that the coordinates of the curve is not “local” to that of the mesh socket. Can anyone tell me how to transform the coordinates of the curve to the local coordinates of the mesh? Thanks!