Fix #1334 Mesh wireframes sometimes do not update

This commit is contained in:
JannisX11 2025-02-06 22:59:07 +01:00
parent 2c0d8f11b3
commit 71b0bd77ea
2 changed files with 23 additions and 0 deletions

View File

@ -1136,6 +1136,10 @@ new NodePreviewController(Mesh, {
Mesh.preview_controller.updatePixelGrid(element);
if (Project.view_mode == 'wireframe' && this.fixWireframe) {
this.fixWireframe(element);
}
this.dispatchEvent('update_geometry', {element});
},
updateFaces(element) {
@ -1447,5 +1451,20 @@ new NodePreviewController(Mesh, {
mesh.add(box);
this.dispatchEvent('update_painting_grid', {element});
},
fixWireframe(element) {
let geometry_orig = element.mesh.geometry;
if (!geometry_orig) return;
let geometry_clone = element.mesh.geometry.clone();
element.mesh.geometry = geometry_clone;
geometry_orig.dispose();
}
})
Blockbench.dispatchEvent('change_view_mode', ({view_mode}) => {
if (view_mode == 'wireframe') {
for (let mesh of Mesh.selected) {
Mesh.preview_controller.fixWireframe(mesh);
}
}
});

View File

@ -2209,6 +2209,7 @@ BARS.defineActions(function() {
material: {name: true, icon: 'pages', condition: () => ((!Toolbox.selected.allowed_view_modes || Toolbox.selected.allowed_view_modes.includes('material')) && TextureGroup.all.find(tg => tg.is_material))},
},
onChange() {
let previous_view_mode = Project.view_mode;
Project.view_mode = this.value;
Canvas.updateViewMode();
if (Modes.id === 'animate') {
@ -2221,6 +2222,9 @@ BARS.defineActions(function() {
if (icon_node) icon_node.replaceWith(icon);
}
})
if (Project.view_mode != previous_view_mode) {
Blockbench.dispatchEvent('change_view_mode', {view_mode: Project.view_mode, previous_view_mode});
}
//Blockbench.showQuickMessage(tl('action.view_mode') + ': ' + tl('action.view_mode.' + this.value));
}
})