diff --git a/src/main/mesh.js b/src/main/mesh.js index 461fce1c..69c98156 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -18,8 +18,8 @@ gapp.main("main.mesh", [], (root) => { const { Quaternion } = THREE; -const { broker } = gapp; const { mesh, moto } = root; +const { broker } = gapp; const { space } = moto; const version = mesh.version = '1.4.9'; diff --git a/src/mesh/api.js b/src/mesh/api.js index 28378e5a..8da34177 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -1179,20 +1179,12 @@ const tool = { let p = worker.model_heal({ id: m.id, opt }).then(data => { - if (data) { - m.reload( - data.vertices, - data.indices, - data.normals - ); - } + data?.length && m.reload(data.vertices); }); promises.push(p); } return new Promise((resolve, reject) => { - Promise.all(promises).then(() => { - resolve(); - }); + Promise.all(promises).then(resolve).catch(error => reject); }); }, diff --git a/src/mesh/model.js b/src/mesh/model.js index 21c18773..02441261 100644 --- a/src/mesh/model.js +++ b/src/mesh/model.js @@ -82,7 +82,7 @@ let materials = mesh.material = { mesh.model = class MeshModel extends mesh.object { constructor(data, id) { super(id); - let { file, mesh, vertices, indices } = data; + let { file, mesh, vertices } = data; if (!mesh) { dbug.error(`'${file}' missing mesh data`); @@ -111,7 +111,7 @@ mesh.model = class MeshModel extends mesh.object { }; this.file = file || 'unnamed'; - this.load(mesh || vertices, indices); + this.load(mesh || vertices); } get type() { @@ -250,14 +250,9 @@ mesh.model = class MeshModel extends mesh.object { }); } - load(vertices, indices) { + load(vertices) { let geo = new BufferGeometry(); geo.setAttribute('position', new BufferAttribute(vertices, 3)); - if (indices) { - // unroll indexed geometries - geo.setIndex(new BufferAttribute(indices, 1)); - geo = geo.toNonIndexed(); - } let meh = this.mesh = new Mesh(geo, [ this.mats.normal, this.mats.face @@ -276,13 +271,10 @@ mesh.model = class MeshModel extends mesh.object { worker.model_load({id: this.id, name: this.file, vertices}); } - reload(vertices, indices) { + reload(vertices) { let was = this.wireframe(false); let geo = this.mesh.geometry; geo.setAttribute('position', new BufferAttribute(vertices, 3)); - if (indices) { - geo.setIndex(new BufferAttribute(indices, 1)); - } // signal util.box3expand that geometry changed geo._model_invalid = true; geo.computeVertexNormals(); diff --git a/src/mesh/object.js b/src/mesh/object.js index d01ff255..f7b73602 100644 --- a/src/mesh/object.js +++ b/src/mesh/object.js @@ -55,6 +55,7 @@ mesh.object = class MeshObject { applyMatrix(elements) { if (elements) { + console.log('matrix', this.type, this.id); this.object.applyMatrix4(new Matrix4().fromArray(elements)); return this.matrixChanged(); } else { diff --git a/src/mesh/work.js b/src/mesh/work.js index c81dbeac..39558b36 100644 --- a/src/mesh/work.js +++ b/src/mesh/work.js @@ -101,7 +101,13 @@ let model = { let { vertices, name, id } = data; let geo = new BufferGeometry(); geo.setAttribute('position', new BufferAttribute(vertices, 3)); - cacheUpdate(id, { name, geo, xmatrix: core_matrix.clone(), trans: undefined, tool: undefined }); + cacheUpdate(id, { + name, + geo, + xmatrix: core_matrix.clone(), + trans: undefined, + tool: undefined + }); }, // return new vertices in world coordinates @@ -294,9 +300,7 @@ let model = { let tool = analyze(id, opt); log(`${id} | unrolling...`); let unrolled = tool.unrolled(); - return { - vertices: unrolled.toFloat32(), - }; + return { vertices: unrolled.toFloat32() }; }, indexFaces(data) {