each part has it's own material

This commit is contained in:
casperlamboo 2017-12-17 16:01:19 +01:00
parent 65592d6f48
commit 01f4b4c1f8

View File

@ -98,18 +98,11 @@ export function generateExportMesh(state, options = {}) {
objectGeometry.mergeVertices(); objectGeometry.mergeVertices();
objectGeometry.applyMatrix(new THREE.Matrix4().multiplyMatrices(objectMatrix, matrix)); objectGeometry.applyMatrix(new THREE.Matrix4().multiplyMatrices(objectMatrix, matrix));
const color = material.color.getHex(); const exportMaterial = new THREE.MeshBasicMaterial({ color: material.color.getHex() });
const side = shapeData.fill ? THREE.FrontSide : THREE.DoubleSide; exportMaterial.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;
const exportMaterial = new THREE.MeshBasicMaterial({ color });
exportMaterial.side = side;
materials.push(exportMaterial); materials.push(exportMaterial);
}
const materialIndex = materials.length;
if (unionGeometry) { if (unionGeometry) {
objectGeometry = new THREE_BSP(objectGeometry, materialIndex); objectGeometry = new THREE_BSP(objectGeometry, materialIndex);
if (exportGeometry) { if (exportGeometry) {