persist vertex edits
This commit is contained in:
parent
94311917e7
commit
8c5309739f
3 changed files with 14 additions and 7 deletions
|
|
@ -112,6 +112,9 @@ let selection = {
|
|||
for (let s of selection.list()) {
|
||||
selection.remove(s);
|
||||
}
|
||||
for (let m of api.model.list()) {
|
||||
m.clearSelections()
|
||||
}
|
||||
},
|
||||
|
||||
visible() {
|
||||
|
|
@ -322,7 +325,7 @@ let tool = {
|
|||
let nm = areas.map(area => new mesh.model({
|
||||
file: (area.length/3).toString(),
|
||||
mesh: area.toFloat32()
|
||||
})).map( nm => nm.applyMatrix4(mcore.multiply(m.mesh.matrixWorld)) );
|
||||
})).map( nm => nm.applyMatrix4(mcore.clone().multiply(m.mesh.matrixWorld)) );
|
||||
newmdl.appendAll(nm);
|
||||
});
|
||||
promises.push(p);
|
||||
|
|
|
|||
|
|
@ -92,8 +92,6 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
|
||||
this.file = file || 'unnamed';
|
||||
this.load(mesh || vertices, indices, normals);
|
||||
// persist in db so it can be restored on page load
|
||||
mapp.db.space.put(this.id, { file, mesh });
|
||||
}
|
||||
|
||||
get type() {
|
||||
|
|
@ -138,6 +136,8 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
this.opacity(1);
|
||||
// this ref allows clicks to be traced to models and groups
|
||||
meh.model = this;
|
||||
// persist in db so it can be restored on page load
|
||||
mapp.db.space.put(this.id, { file: this.file, mesh: vertices });
|
||||
// sync data to worker
|
||||
worker.model_load({id: this.id, name: this.file, vertices, indices});
|
||||
}
|
||||
|
|
@ -150,6 +150,8 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
if (indices) geo.setIndex(new BufferAttribute(indices, 1));
|
||||
geo.attributes.position.needsUpdate = true;
|
||||
if (!normals) geo.computeVertexNormals();
|
||||
// persist in db so it can be restored on page load
|
||||
mapp.db.space.put(this.id, { file: this.file, mesh: vertices });
|
||||
// sync data to worker
|
||||
worker.model_load({id: this.id, name: this.name, vertices, indices});
|
||||
// restore wireframe state
|
||||
|
|
@ -298,7 +300,9 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
}
|
||||
|
||||
clearSelections() {
|
||||
console.log('todo: clearSelections');
|
||||
// clear face selections (since they've been deleted);
|
||||
this.sel.faces = [];
|
||||
this.updateSelections();
|
||||
}
|
||||
|
||||
deleteSelections(mode) {
|
||||
|
|
@ -413,7 +417,7 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix
|
||||
}).then(data => {
|
||||
let { faces, edges, verts, point } = data;
|
||||
console.log({data});
|
||||
// console.log({data});
|
||||
// this.toggleSelectedVertices(verts);
|
||||
this.toggleSelectedFaces(faces);
|
||||
this.updateSelections();
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ let model = {
|
|||
x = v3.x; y = v3.y; z = v3.z;
|
||||
let arr = cache[id].geo.attributes.position.array;
|
||||
// distance tolerance for click to vertex (rough distance)
|
||||
let eps = 1;
|
||||
let eps = 0.25;
|
||||
let faces = [];
|
||||
let verts = [];
|
||||
let edges = [];
|
||||
|
|
@ -129,7 +129,7 @@ let model = {
|
|||
if (dx < eps && dy < eps && dz < eps) {
|
||||
faces.addOnce(face);
|
||||
verts.push(vert);
|
||||
console.log(`match @ ${i-3} = ${face}`, ax, ay, az);
|
||||
// console.log(`match @ ${i-3} = ${face}`, ax, ay, az);
|
||||
}
|
||||
}
|
||||
// no matches and we look at the line segments from the provided face
|
||||
|
|
|
|||
Loading…
Reference in a new issue