I am applying CSG on a .glb that already contains a color attribute, the thing is that when the evaluation is done on the geometry the color attriute array fills with 0's removing the original colors of the geometry. Is is possible to get the colors of my original geometry back with the CSG applied on the geometry.
here's a small code showing what the issue is:
csgEvaluator = new tbc.Evaluator();
csgEvaluator.attributes = ["position", "normal", "color"];
csgEvaluator.useGroups = false;
const loader = new GLTFLoader();
loader.load(
"https://cdn.glitch.global/49e0e39d-66ab-4caf-9837-c5105ddd573a/full_segmentation.glb?v=1724934547183",
function (gltf) {
gltf.scene.traverse((e) => {
if (e.isMesh) {
result = e;
}
});
result.geometry.center();
result.geometry.computeVertexNormals();
let resultMaterial = new THREE.MeshLambertMaterial({
side: THREE.DoubleSide,
alphaToCoverage: true,
stencilWrite: true,
stencilRef: 0,
vertexColors: true,
});
result.material = resultMaterial;
meshBrush = new tbc.Operation(result.geometry, resultMaterial);
console.log(meshBrush.geometry.attributes.color.array); // The color array is exactly the same as it should be
{
inside = new tbc.Operation(
new THREE.BoxGeometry(100, 100, 30),
resultMaterial
);
meshBrush.add(inside);
inside.operation = tbc.SUBTRACTION;
inside.position.set(0, 0, 50);
}
mesh = csgEvaluator.evaluateHierarchy(meshBrush, result);
console.log(mesh.geometry.attributes.color.array); // The color array is completely filled with 0's here
);
Description:
I am applying CSG on a
.glb
that already contains a color attribute, the thing is that when the evaluation is done on the geometry the color attriute array fills with 0's removing the original colors of the geometry. Is is possible to get the colors of my original geometry back with the CSG applied on the geometry.here's a small code showing what the issue is: