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
This commit is contained in:
JannisX11 2022-03-30 19:01:28 +02:00
parent cca7221ea1
commit d3cd51219c
4 changed files with 35 additions and 17 deletions

View File

@ -450,14 +450,14 @@ function setupInterface() {
} }
]) ])
document.addEventListener('contextmenu', (event) => { document.oncontextmenu = function (event) {
if (!$(event.target).hasClass('allow_default_menu') && event instanceof PointerEvent == false) { if (!$(event.target).hasClass('allow_default_menu') && event instanceof TouchEvent == false) {
if (event.target.nodeName === 'INPUT' && $(event.target).is(':focus')) { if (event.target.nodeName === 'INPUT' && $(event.target).is(':focus')) {
Interface.text_edit_menu.open(event, event.target) Interface.text_edit_menu.open(event, event.target)
} }
return false; return false;
} }
}) }
//Scrolling //Scrolling
$('input[type="range"]').on('mousewheel', function () { $('input[type="range"]').on('mousewheel', function () {

View File

@ -711,6 +711,9 @@ function setupMobilePanelSelector() {
}, },
template: ` template: `
<div id="panel_selector_bar"> <div id="panel_selector_bar">
<div class="panel_selector" :class="{selected: selected == null}" @click="select(null)">
<div class="icon_wrapper"><i class="material-icons icon">3d_rotation</i></div>
</div>
<div class="panel_selector" :class="{selected: selected == panel.id}" v-for="panel in panels()" v-if="Condition(panel.condition)" @click="select(panel)"> <div class="panel_selector" :class="{selected: selected == panel.id}" v-for="panel in panels()" v-if="Condition(panel.condition)" @click="select(panel)">
<div class="icon_wrapper" v-html="getIconNode(panel.icon).outerHTML"></div> <div class="icon_wrapper" v-html="getIconNode(panel.icon).outerHTML"></div>
</div> </div>

View File

@ -517,9 +517,6 @@ class Cube extends OutlinerElement {
var ph = Project.texture_height; var ph = Project.texture_height;
if (scope.autouv === 2) { if (scope.autouv === 2) {
//Relative UV //Relative UV
function gt(n) {
return (n+16)%16
}
var all_faces = ['north', 'south', 'west', 'east', 'up', 'down'] var all_faces = ['north', 'south', 'west', 'east', 'up', 'down']
all_faces.forEach(function(side) { all_faces.forEach(function(side) {
var uv = scope.faces[side].uv.slice() var uv = scope.faces[side].uv.slice()
@ -573,14 +570,28 @@ class Cube extends OutlinerElement {
]; ];
break; break;
} }
//var texture = scope.faces[side] // Clamp to UV map boundaries
//var fr_u = 16 / Project.texture_width; if (Math.max(uv[0], uv[2]) > Project.texture_width) {
//var fr_v = 16 / Project.texture_height; let offset = Math.max(uv[0], uv[2]) - Project.texture_width;
//uv.forEach(function(s, uvi) { uv[0] -= offset;
// s *= (uvi%2 ? fr_v : fr_u); uv[2] -= offset;
// uv[uvi] = limitNumber(s, 0, 16) }
//}) if (Math.min(uv[0], uv[2]) < 0) {
scope.faces[side].uv = uv 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) Canvas.updateUV(scope)
} else if (scope.autouv === 1) { } else if (scope.autouv === 1) {
@ -594,8 +605,6 @@ class Cube extends OutlinerElement {
if (rot === 90 || rot === 270) { if (rot === 90 || rot === 270) {
size.reverse() size.reverse()
} }
//size[0] *= 16/Project.texture_width;
//size[1] *= 16/Project.texture_height;
//Limit Input to 16 //Limit Input to 16
size[0] = Math.clamp(size[0], -Project.texture_width, Project.texture_width) size[0] = Math.clamp(size[0], -Project.texture_width, Project.texture_width)
size[1] = Math.clamp(size[1], -Project.texture_height, Project.texture_height) size[1] = Math.clamp(size[1], -Project.texture_height, Project.texture_height)

View File

@ -1027,7 +1027,13 @@ class Preview {
} }
mouseup(event) { mouseup(event) {
this.showContextMenu(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(); unselectAll();
} }
delete this.selection.click_target; delete this.selection.click_target;