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()) {
|
for (let s of selection.list()) {
|
||||||
selection.remove(s);
|
selection.remove(s);
|
||||||
}
|
}
|
||||||
|
for (let m of api.model.list()) {
|
||||||
|
m.clearSelections()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
visible() {
|
visible() {
|
||||||
|
|
@ -322,7 +325,7 @@ let tool = {
|
||||||
let nm = areas.map(area => new mesh.model({
|
let nm = areas.map(area => new mesh.model({
|
||||||
file: (area.length/3).toString(),
|
file: (area.length/3).toString(),
|
||||||
mesh: area.toFloat32()
|
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);
|
newmdl.appendAll(nm);
|
||||||
});
|
});
|
||||||
promises.push(p);
|
promises.push(p);
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,6 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
|
|
||||||
this.file = file || 'unnamed';
|
this.file = file || 'unnamed';
|
||||||
this.load(mesh || vertices, indices, normals);
|
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() {
|
get type() {
|
||||||
|
|
@ -138,6 +136,8 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
this.opacity(1);
|
this.opacity(1);
|
||||||
// this ref allows clicks to be traced to models and groups
|
// this ref allows clicks to be traced to models and groups
|
||||||
meh.model = this;
|
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
|
// sync data to worker
|
||||||
worker.model_load({id: this.id, name: this.file, vertices, indices});
|
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));
|
if (indices) geo.setIndex(new BufferAttribute(indices, 1));
|
||||||
geo.attributes.position.needsUpdate = true;
|
geo.attributes.position.needsUpdate = true;
|
||||||
if (!normals) geo.computeVertexNormals();
|
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
|
// sync data to worker
|
||||||
worker.model_load({id: this.id, name: this.name, vertices, indices});
|
worker.model_load({id: this.id, name: this.name, vertices, indices});
|
||||||
// restore wireframe state
|
// restore wireframe state
|
||||||
|
|
@ -298,7 +300,9 @@ mesh.model = class MeshModel extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
clearSelections() {
|
clearSelections() {
|
||||||
console.log('todo: clearSelections');
|
// clear face selections (since they've been deleted);
|
||||||
|
this.sel.faces = [];
|
||||||
|
this.updateSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSelections(mode) {
|
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
|
id: this.id, x, y:-z, z:y, a, b, c, matrix: this.matrix
|
||||||
}).then(data => {
|
}).then(data => {
|
||||||
let { faces, edges, verts, point } = data;
|
let { faces, edges, verts, point } = data;
|
||||||
console.log({data});
|
// console.log({data});
|
||||||
// this.toggleSelectedVertices(verts);
|
// this.toggleSelectedVertices(verts);
|
||||||
this.toggleSelectedFaces(faces);
|
this.toggleSelectedFaces(faces);
|
||||||
this.updateSelections();
|
this.updateSelections();
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ let model = {
|
||||||
x = v3.x; y = v3.y; z = v3.z;
|
x = v3.x; y = v3.y; z = v3.z;
|
||||||
let arr = cache[id].geo.attributes.position.array;
|
let arr = cache[id].geo.attributes.position.array;
|
||||||
// distance tolerance for click to vertex (rough distance)
|
// distance tolerance for click to vertex (rough distance)
|
||||||
let eps = 1;
|
let eps = 0.25;
|
||||||
let faces = [];
|
let faces = [];
|
||||||
let verts = [];
|
let verts = [];
|
||||||
let edges = [];
|
let edges = [];
|
||||||
|
|
@ -129,7 +129,7 @@ let model = {
|
||||||
if (dx < eps && dy < eps && dz < eps) {
|
if (dx < eps && dy < eps && dz < eps) {
|
||||||
faces.addOnce(face);
|
faces.addOnce(face);
|
||||||
verts.push(vert);
|
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
|
// no matches and we look at the line segments from the provided face
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue