update export material

export material now has side property so we can differentiate between
open and closed shapes
This commit is contained in:
casperlamboo 2017-12-17 12:07:19 +01:00
parent 162016bbc9
commit c31115aa0b

View File

@ -101,11 +101,16 @@ export function generateExportMesh(state, options = {}) {
objectGeometry.mergeVertices();
objectGeometry.applyMatrix(new THREE.Matrix4().multiplyMatrices(objectMatrix, matrix));
const colorHex = material.color.getHex();
let materialIndex = materials.findIndex(exportMaterial => exportMaterial.color.getHex() === colorHex);
const color = material.color.getHex();
const side = shapeData.fill ? THREE.FrontSide : THREE.DoubleSide;
let materialIndex = materials.findIndex(exportMaterial => {
return exportMaterial.color.getHex() === color && exportMaterial.side === side;
});
if (materialIndex === -1) {
materialIndex = materials.length;
materials.push(material);
const exportMaterial = new THREE.MeshBasicMaterial({ color });
exportMaterial.side = side;
materials.push(exportMaterial);
}
if (unionGeometry) {