Closed Kalabedo closed 11 months ago
From the docs:
CSG results use Geometry.drawRange to help maintain performance which can cause three.js exporters to fail to export the geometry correctly. It is necessary to convert the geometry to remove the use of draw range before exporting with three.js exporters.
Either way this is an issue related to an exporter if three.js is not exporting geometry as it's rendered in the application and should be reported elsewhere. At least a warning should be logged.
Either way this is an issue related to an exporter if three.js is not exporting geometry as it's rendered in the application and should be reported elsewhere. At least a warning should be logged.
I tried with other CSG libraries and the exporting works fine so i thought the implementation in this library does something different with the materials
Here is a fix:
// CSG
const brush1 = new Brush( geometry );
brush1.material = material
brush1.updateMatrixWorld();
const brush2 = new Brush( geometry2 );
brush2.material = material2
brush2.position.z = 0.45;
brush2.updateMatrixWorld();
const evaluator = new Evaluator();
evaluator.useGroups = true
evaluator.consolidateMaterials = true
const result = evaluator.evaluate( brush1, brush2, SUBTRACTION );
let index = [];
for (let i = 0; i < result.geometry.attributes.position.count; i++)
index.push(i);
result.geometry.setIndex(index);
scene.add(result)
With the help of thrax, we found out, that the geometry is not indexed after the subtraction. setting an index fixed the issue with exporting. So you were right i think, it is an Exporter issue
I used this library to cut stuff from simple geometries when i want to export the newly built geometries the material on it is not correct. In the renderer everything looks fine. As soon as i export the scene via GLTFExporter the mesh has two seperate textures on top of each other. Resulting in this (opened in Blender):
In the renderer it looks like this:
This is the code i'm using (i played with useGroups / consolidateMaterials without sucess):