Result object of csg evaluator doesn't have textures
pceeee opened this issue · 8 comments
Hi, my mesh "sportello" has a texture, but "resultObject" takes only the primary color from the texture, is it possibile to apply the texture to the result of the csg evaluator?
I have tried applying the texture directly to "resultObject" using the map: texture or material.map = texture, but i get the same result.
if ( needsUpdate ) {
needsUpdate = false;
sportello.updateMatrixWorld();
foro.updateMatrixWorld();
foro2.updateMatrixWorld();
foro3.updateMatrixWorld();
foro4.updateMatrixWorld();
divisore.updateMatrixWorld();
let finalBrush = brushes[0];
csgEvaluator.useGroups = params.useGroups;
csgEvaluator.consolidateGroups = params.consolidateGroups;
for (let i = 1, l = brushes.length; i < l; i++) {
const b = brushes[i];
finalBrush = csgEvaluator.evaluate(finalBrush, b, ADDITION);
finalBrush.material = foro.material;
}
csgEvaluator.evaluate(sportello, finalBrush, params.operation, resultObject);
resultObject.material = materialMap.get(sportello.material);
if ( enableDebugTelemetry ) {
edgesHelper.setEdges( csgEvaluator.debug.intersectionEdges );
trisHelper.setTriangles( [
...csgEvaluator.debug.triangleIntersectsA.getTrianglesAsArray(),
...csgEvaluator.debug.triangleIntersectsA.getIntersectionsAsArray()
] );
}
}
Please provide a live example of what you're having issues with.
This is not a live example. Please make an editable example using jsfiddle, codesandbox, etc.
https://jsfiddle.net/lmigani/bthp50v7/38/
The project base was this: https://gkjohnson.github.io/three-bvh-csg/examples/bundle/simple.html
Your demo page does not work. Have you tested it? I'm happy to take a look but I'm not planning to spend my time fixing your broken demonstration code just so I can understand your issue. If you'd like help you need to make an effort to provide a live, working demonstration that shows your problem, as I've asked for twice now.
Sorry for the inconvenience, the preview it's working now.
You're removing the UVs from the result which are needed for textures. Make sure the UVs are included:
csgEvaluator.attributes = [ 'position', 'normal' ]; // make sure "uv" is included in the set of attributes
Thank you very much