From d3cd51219cdfbc38be90cb0f145ad800d721d7ed Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Wed, 30 Mar 2022 19:01:28 +0200 Subject: [PATCH] Fix context menus appearing in web app Add back "3D Preview" navigation button on mobile Fix Canvas Unselect not working on touch screens Fix #1216 Relative auto UV can go out of bounds --- js/interface/interface.js | 6 +++--- js/interface/panels.js | 3 +++ js/outliner/cube.js | 35 ++++++++++++++++++++++------------- js/preview/preview.js | 8 +++++++- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/js/interface/interface.js b/js/interface/interface.js index 19098bd..fdb9cf2 100644 --- a/js/interface/interface.js +++ b/js/interface/interface.js @@ -450,14 +450,14 @@ function setupInterface() { } ]) - document.addEventListener('contextmenu', (event) => { - if (!$(event.target).hasClass('allow_default_menu') && event instanceof PointerEvent == false) { + document.oncontextmenu = function (event) { + if (!$(event.target).hasClass('allow_default_menu') && event instanceof TouchEvent == false) { if (event.target.nodeName === 'INPUT' && $(event.target).is(':focus')) { Interface.text_edit_menu.open(event, event.target) } return false; } - }) + } //Scrolling $('input[type="range"]').on('mousewheel', function () { diff --git a/js/interface/panels.js b/js/interface/panels.js index 35da4df..49b0286 100644 --- a/js/interface/panels.js +++ b/js/interface/panels.js @@ -711,6 +711,9 @@ function setupMobilePanelSelector() { }, template: `
+
+
3d_rotation
+
diff --git a/js/outliner/cube.js b/js/outliner/cube.js index 9480f63..5a2f37e 100644 --- a/js/outliner/cube.js +++ b/js/outliner/cube.js @@ -517,9 +517,6 @@ class Cube extends OutlinerElement { var ph = Project.texture_height; if (scope.autouv === 2) { //Relative UV - function gt(n) { - return (n+16)%16 - } var all_faces = ['north', 'south', 'west', 'east', 'up', 'down'] all_faces.forEach(function(side) { var uv = scope.faces[side].uv.slice() @@ -573,14 +570,28 @@ class Cube extends OutlinerElement { ]; break; } - //var texture = scope.faces[side] - //var fr_u = 16 / Project.texture_width; - //var fr_v = 16 / Project.texture_height; - //uv.forEach(function(s, uvi) { - // s *= (uvi%2 ? fr_v : fr_u); - // uv[uvi] = limitNumber(s, 0, 16) - //}) - scope.faces[side].uv = uv + // Clamp to UV map boundaries + if (Math.max(uv[0], uv[2]) > Project.texture_width) { + let offset = Math.max(uv[0], uv[2]) - Project.texture_width; + uv[0] -= offset; + uv[2] -= offset; + } + if (Math.min(uv[0], uv[2]) < 0) { + let offset = Math.min(uv[0], uv[2]); + uv[0] = Math.clamp(uv[0] - offset, 0, Project.texture_width); + uv[2] = Math.clamp(uv[2] - offset, 0, Project.texture_width); + } + if (Math.max(uv[1], uv[3]) > Project.texture_height) { + let offset = Math.max(uv[1], uv[3]) - Project.texture_height; + uv[1] -= offset; + uv[3] -= offset; + } + if (Math.min(uv[1], uv[3]) < 0) { + let offset = Math.min(uv[1], uv[3]); + uv[1] = Math.clamp(uv[1] - offset, 0, Project.texture_height); + uv[3] = Math.clamp(uv[3] - offset, 0, Project.texture_height); + } + scope.faces[side].uv = uv; }) Canvas.updateUV(scope) } else if (scope.autouv === 1) { @@ -594,8 +605,6 @@ class Cube extends OutlinerElement { if (rot === 90 || rot === 270) { size.reverse() } - //size[0] *= 16/Project.texture_width; - //size[1] *= 16/Project.texture_height; //Limit Input to 16 size[0] = Math.clamp(size[0], -Project.texture_width, Project.texture_width) size[1] = Math.clamp(size[1], -Project.texture_height, Project.texture_height) diff --git a/js/preview/preview.js b/js/preview/preview.js index 7b39fae..d09c7b4 100644 --- a/js/preview/preview.js +++ b/js/preview/preview.js @@ -1027,7 +1027,13 @@ class Preview { } mouseup(event) { this.showContextMenu(event); - if (settings.canvas_unselect.value && (event.which === 1 || event.which === 3) && this.controls.hasMoved === false && !this.selection.activated && !Transformer.dragging && !this.selection.click_target) { + if (settings.canvas_unselect.value && + (event.which === 1 || event.which === 3 || event instanceof TouchEvent) && + !this.controls.hasMoved && + !this.selection.activated && + !Transformer.dragging && + !this.selection.click_target + ) { unselectAll(); } delete this.selection.click_target;