Fix inverted normals when deleting vertices

Remove shadow from floating reference images
This commit is contained in:
JannisX11 2023-04-17 13:51:18 +02:00
parent 99558d2145
commit 6907ebeecc
3 changed files with 15 additions and 9 deletions

View File

@ -910,7 +910,7 @@
.reference_image[reference_layer=float] {
z-index: 8;
}
.reference_image[reference_layer=float] > img {
.reference_image.selected[reference_layer=float] > img {
box-shadow: 3px 3px 10px rgb(0 0 0 / 70%);
}
#work_screen.reference_image_mode .reference_image {

View File

@ -1896,16 +1896,21 @@ const BARS = {
})
} else if (BarItems.selection_mode.value == 'vertex' && selected_vertices.length < Object.keys(mesh.vertices).length) {
selected_vertices.forEach(vertex_key => {
delete mesh.vertices[vertex_key];
selected_vertices.forEach(vkey => {
for (let key in mesh.faces) {
let face = mesh.faces[key];
if (!face.vertices.includes(vertex_key)) continue;
if (!face.vertices.includes(vkey)) continue;
if (face.vertices.length > 2) {
face.vertices.remove(vertex_key);
delete face.uv[vertex_key];
let initial_normal;
if (face.vertices.length == 4) {
initial_normal = face.getNormal();
}
face.vertices.remove(vkey);
delete face.uv[vkey];
if (face.vertices.length == 3 && face.getAngleTo(initial_normal) > 90) {
face.invert();
}
if (face.vertices.length == 2) {
for (let fkey2 in mesh.faces) {
if (fkey2 != key && !face.vertices.find(vkey => !mesh.faces[fkey2].vertices.includes(vkey))) {
@ -1918,6 +1923,7 @@ const BARS = {
delete mesh.faces[key];
}
}
delete mesh.vertices[vkey];
})
} else {
Mesh.selected.remove(mesh);

View File

@ -151,9 +151,9 @@ class MeshFace extends Face {
crawl(this);
return keys;
}
getAngleTo(other_face) {
getAngleTo(other) {
let a = new THREE.Vector3().fromArray(this.getNormal());
let b = new THREE.Vector3().fromArray(other_face.getNormal());
let b = new THREE.Vector3().fromArray(other instanceof Array ? other : other.getNormal());
return Math.radToDeg(a.angleTo(b));
}
invert() {