Fix issue with UV position when switching tabs

Fix #1344 Template texture filtering
This commit is contained in:
JannisX11 2022-03-14 21:38:37 +01:00
parent b7f06705a0
commit cb90fa1221
4 changed files with 18 additions and 16 deletions

View File

@ -482,13 +482,9 @@ class Panel {
this.node.style.zIndex = '';
}
position_data.slot = slot;
this.update();
if (Panels[this.id]) {
// Only update after initial setup
if (this.onResize) {
this.onResize()
}
updateInterface()
this.dispatchEvent('moved_to', {slot, ref_panel, before, previous_slot: this.previous_slot});
}

View File

@ -141,7 +141,8 @@ class ModelProject {
if (this === Project) return true;
if (this.locked || Project.locked) return false;
if (Project) {
Project.unselect()
Project.unselect();
Blockbench.addFlag('switching_project');
} else {
Interface.tab_bar.new_tab.visible = false;
}
@ -184,6 +185,8 @@ class ModelProject {
Interface.Panels.skin_pose.inside_vue.pose = this.skin_pose;
UVEditor.loadViewportOffset();
Modes.options[this.mode].select();
BarItems.lock_motion_trail.value = !!Project.motion_trail_lock;
@ -202,8 +205,6 @@ class ModelProject {
}
})
UVEditor.loadViewportOffset();
if (this.EditSession) {
Interface.Panels.chat.inside_vue.chat_history = this.EditSession.chat_history;
this.EditSession.catchUp();
@ -227,6 +228,7 @@ class ModelProject {
delete this.on_next_upen;
}
})
Blockbench.removeFlag('switching_project');
return true;
}
unselect(closing) {

View File

@ -1145,6 +1145,7 @@ const TextureGenerator = {
rot -= 90;
}
}
ctx.imageSmoothingEnabled = false;
ctx.drawImage(
texture.img,
src.ax/Project.texture_width * texture.img.naturalWidth,
@ -1210,6 +1211,7 @@ const TextureGenerator = {
}
ctx.closePath();
ctx.clip();
ctx.imageSmoothingEnabled = false;
ctx.drawImage(
texture.img,

View File

@ -596,18 +596,18 @@ const UVEditor = {
},
saveViewportOffset() {
let uv_viewport = this.vue.$refs.viewport;
let uv_margin = this.vue.getFrameMargin();
if (!uv_viewport || !uv_margin) return;
Project.uv_viewport.offset[0] = uv_viewport.scrollLeft - uv_margin[0];
Project.uv_viewport.offset[1] = uv_viewport.scrollTop - uv_margin[1];
if (!uv_viewport || Blockbench.hasFlag('switching_project')) return;
Project.uv_viewport.offset[0] = (uv_viewport.scrollLeft - this.width/2) / this.vue.inner_width;
Project.uv_viewport.offset[1] = (uv_viewport.scrollTop - this.height/2) / this.vue.inner_height;
},
loadViewportOffset() {
let uv_viewport = this.vue.$refs.viewport;
let uv_margin = this.vue.getFrameMargin();
if (!uv_viewport) return;
uv_viewport.scrollLeft = Project.uv_viewport.offset[0] + uv_margin[0];
uv_viewport.scrollTop = Project.uv_viewport.offset[1] + uv_margin[1];
UVEditor.setZoom(Project.uv_viewport.zoom);
Vue.nextTick(() => {
uv_viewport.scrollLeft = Project.uv_viewport.offset[0] * this.vue.inner_width + this.width/2;
uv_viewport.scrollTop = Project.uv_viewport.offset[1] * this.vue.inner_height + this.height/2;
})
},
//Events
@ -2849,7 +2849,9 @@ Interface.definePanels(function() {
UVEditor.saveViewportOffset();
})
UVEditor.panel.on('moved_to', (data) => {
UVEditor.loadViewportOffset();
Vue.nextTick(() => {
UVEditor.loadViewportOffset();
})
})
Toolbars.uv_editor.toPlace()