simplify export

This commit is contained in:
casperlamboo 2017-12-12 17:18:20 +01:00
parent 24a41fd933
commit da3e109cdd

View File

@ -86,7 +86,6 @@ export function generateExportMesh(state, options = {}) {
shapesManager.update(exportState); shapesManager.update(exportState);
const materials = []; const materials = [];
const objectMatrix = new THREE.Matrix4();
let exportGeometry; let exportGeometry;
shapesManager.traverse(mesh => { shapesManager.traverse(mesh => {
const shapeData = exportState.objectsById[mesh.name]; const shapeData = exportState.objectsById[mesh.name];
@ -95,7 +94,7 @@ export function generateExportMesh(state, options = {}) {
let objectGeometry = geometry.clone(); let objectGeometry = geometry.clone();
objectGeometry.mergeVertices(); objectGeometry.mergeVertices();
objectGeometry.applyMatrix(objectMatrix.multiplyMatrices(state.spaces[shapeData.space].matrix, matrix)); objectGeometry.applyMatrix(new THREE.Matrix4().multiplyMatrices(state.spaces[shapeData.space].matrix, matrix));
const colorHex = material.color.getHex(); const colorHex = material.color.getHex();
let materialIndex = materials.findIndex(exportMaterial => exportMaterial.color.getHex() === colorHex); let materialIndex = materials.findIndex(exportMaterial => exportMaterial.color.getHex() === colorHex);
@ -104,13 +103,12 @@ export function generateExportMesh(state, options = {}) {
materials.push(material); materials.push(material);
} }
if (unionGeometry) objectGeometry = new THREE_BSP(objectGeometry, materialIndex);
if (unionGeometry) { if (unionGeometry) {
if (!exportGeometry) { objectGeometry = new THREE_BSP(objectGeometry, materialIndex);
exportGeometry = objectGeometry; if (exportGeometry) {
} else {
exportGeometry = exportGeometry.union(objectGeometry); exportGeometry = exportGeometry.union(objectGeometry);
} else {
exportGeometry = objectGeometry;
} }
} else { } else {
if (!exportGeometry) exportGeometry = new THREE.Geometry(); if (!exportGeometry) exportGeometry = new THREE.Geometry();