Implement #1024 Mesh stats on status bar

Fix #1085 Inverted rear faces when exporting to .obj
Fixed transform tool options missing on mobile
Fix menu positions on mobile
Fix texture updating when changed while tab is not open
This commit is contained in:
JannisX11 2021-10-09 00:31:17 +03:00
parent 5da83af608
commit feaafd7131
12 changed files with 85 additions and 14 deletions

View File

@ -920,6 +920,9 @@
bottom: 0;
left: 0;
}
#status_bar .status_selection_info {
color: var(--color-subtle_text);
}
#status_bar .sidebar_toggle_button {
cursor: pointer;
padding: 2px;

View File

@ -148,6 +148,7 @@ function updateSelection(options = {}) {
BarItems.cube_counter.update();
updateNslideValues();
Interface.status_bar.vue.updateSelectionInfo();
if (settings.highlight_cubes.value || (Mesh.all[0])) updateCubeHighlights();
Canvas.updatePivotMarker();
Transformer.updateSelection();

View File

@ -2072,6 +2072,17 @@ const BARS = {
'lock_motion_trail'
]
})
if (Blockbench.isMobile) {
[Toolbars.element_position,
Toolbars.element_size,
Toolbars.element_origin,
Toolbars.element_rotation
].forEach(toolbar => {
Toolbars.main_tools.children.forEach(child => {
toolbar.add(child);
})
})
}
Blockbench.onUpdateTo('3.7', () => {
Toolbars.main_tools.add(BarItems.lock_motion_trail, -1);
})

View File

@ -794,6 +794,7 @@ onVueSetup(function() {
Prop,
isMobile: Blockbench.isMobile,
streamer_mode: settings.streamer_mode.value,
selection_info: '',
Format: null
},
methods: {
@ -803,6 +804,46 @@ onVueSetup(function() {
toggleStreamerMode() {
ActionControl.select(`setting: ${tl('settings.streamer_mode')}`);
},
updateSelectionInfo() {
let selection_mode = BarItems.selection_mode.value;
if (Modes.edit && Mesh.selected.length && selection_mode !== 'object') {
if (selection_mode == 'face') {
let total = 0, selected = 0;
Mesh.selected.forEach(mesh => total += Object.keys(mesh.faces).length);
Mesh.selected.forEach(mesh => mesh.forAllFaces(face => selected += (face.isSelected() ? 1 : 0)));
this.selection_info = tl('status_bar.selection.faces', `${selected} / ${total}`);
}
if (selection_mode == 'line') {
let total = 0, selected = 0;
Mesh.selected.forEach(mesh => {
let selected_vertices = mesh.getSelectedVertices();
let processed_lines = [];
mesh.forAllFaces(face => {
let vertices = face.getSortedVertices();
vertices.forEach((vkey, i) => {
let vkey2 = vertices[i+1] || vertices[0];
if (!processed_lines.find(processed => processed.includes(vkey) && processed.includes(vkey2))) {
processed_lines.push([vkey, vkey2]);
total += 1;
if (selected_vertices.includes(vkey) && selected_vertices.includes(vkey2)) {
selected += 1;
}
}
})
})
})
this.selection_info = tl('status_bar.selection.lines', `${selected} / ${total}`);
}
if (selection_mode == 'vertex') {
let total = 0, selected = 0;
Mesh.selected.forEach(mesh => total += Object.keys(mesh.vertices).length);
Mesh.selected.forEach(mesh => selected += mesh.getSelectedVertices().length);
this.selection_info = tl('status_bar.selection.vertices', `${selected} / ${total}`);
}
} else {
this.selection_info = '';
}
},
toggleSidebar: Interface.toggleSidebar,
getIconNode: Blockbench.getIconNode
},
@ -827,6 +868,7 @@ onVueSetup(function() {
{{ Prop.file_name }}
</div>
<div id="status_message" class="hidden"></div>
<div class="status_selection_info">{{ selection_info }}</div>
<div class="f_right">
{{ Prop.fps }} FPS
</div>

View File

@ -312,6 +312,7 @@ class Menu {
if (offset_left > window.innerWidth - el_width) {
offset_left -= el_width
if (position && position.clientWidth) offset_left += position.clientWidth;
if (offset_left < 0) offset_left = 0;
}
if (offset_top > window_height - el_height ) {
offset_top -= el_height;

View File

@ -121,7 +121,7 @@ var codec = new Codec('obj', {
switch (key) {
case 'north': vertices = [2, 5, 7, 4]; break;
case 'east': vertices = [1, 2, 4, 3]; break;
case 'south': vertices = [1, 6, 8, 3]; break;
case 'south': vertices = [6, 1, 3, 8]; break;
case 'west': vertices = [5, 6, 8, 7]; break;
case 'up': vertices = [5, 2, 1, 6]; break;
case 'down': vertices = [8, 3, 4, 7]; break;

View File

@ -153,7 +153,7 @@ class Texture {
var size_control = {};
this.img.onload = function() {
if (!this.src) return;
if (!this.src || Texture.all.indexOf(scope) == -1) return;
this.tex.needsUpdate = true;
scope.width = img.naturalWidth;
scope.height = img.naturalHeight;
@ -523,7 +523,16 @@ class Texture {
if (eventType == 'change') {
if (timeout) clearTimeout(timeout)
timeout = setTimeout(() => {
scope.reloadTexture();
if (Texture.all.includes(scope)) {
scope.reloadTexture();
} else {
let project = ModelProject.find(project => project.textures.includes(scope));
if (project) {
project.whenNextOpen(() => {
scope.reloadTexture();
})
}
}
}, 60)
}
})

View File

@ -2278,6 +2278,7 @@ Interface.definePanels(function() {
elements.forEach(element => {
this.selected_faces.forEach(key => {
let face = element.faces[key];
if (!face) return;
face.vertices.forEach(vertex_key => {
if (this.selected_vertices[element.uuid] && this.selected_vertices[element.uuid].includes(vertex_key)) {
x = Math.clamp(x, -face.uv[vertex_key][0], Project.texture_width - face.uv[vertex_key][0]);

File diff suppressed because one or more lines are too long

View File

@ -145,6 +145,9 @@
"status_bar.recording_gif":"Recording GIF",
"status_bar.processing_gif":"Processing GIF",
"status_bar.toggle_sidebar": "Toggle Sidebar",
"status_bar.selection.faces": "%0 Faces",
"status_bar.selection.lines": "%0 Lines",
"status_bar.selection.vertices": "%0 Vertices",
"message.canvas_limit_error.title": "Canvas Limit Error",
"message.canvas_limit_error.message": "The action could not be performed correctly because the format limits the canvas to 48 units. Shift the pivot point to prevent this.",

18
package-lock.json generated
View File

@ -2597,9 +2597,9 @@
}
},
"core-js": {
"version": "3.17.3",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.17.3.tgz",
"integrity": "sha512-lyvajs+wd8N1hXfzob1LdOCCHFU4bGMbqqmLn1Q4QlCpDqWPpGf+p0nj+LNrvDDG33j0hZXw2nsvvVpHysxyNw==",
"version": "3.18.2",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.18.2.tgz",
"integrity": "sha512-zNhPOUoSgoizoSQFdX1MeZO16ORRb9FFQLts8gSYbZU5FcgXhp24iMWMxnOQo5uIaIG7/6FA/IqJPwev1o9ZXQ==",
"dev": true,
"optional": true
},
@ -2848,9 +2848,9 @@
}
},
"electron": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/electron/-/electron-13.3.0.tgz",
"integrity": "sha512-d/BvOLDjI4i7yf9tqCuLL2fFGA2TrM/D9PyRpua+rJolG0qrwp/FohP02L0m+44kmPpofIo4l3NPwLmzyKKimA==",
"version": "13.5.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-13.5.1.tgz",
"integrity": "sha512-ZyxhIhmdaeE3xiIGObf0zqEyCyuIDqZQBv9NKX8w5FNzGm87j4qR0H1+GQg6vz+cA1Nnv1x175Zvimzc0/UwEQ==",
"dev": true,
"requires": {
"@electron/get": "^1.0.1",
@ -2859,9 +2859,9 @@
},
"dependencies": {
"@types/node": {
"version": "14.17.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.17.tgz",
"integrity": "sha512-niAjcewgEYvSPCZm3OaM9y6YQrL2SEPH9PymtE6fuZAvFiP6ereCcvApGl2jKTq7copTIguX3PBvfP08LN4LvQ==",
"version": "14.17.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.21.tgz",
"integrity": "sha512-zv8ukKci1mrILYiQOwGSV4FpkZhyxQtuFWGya2GujWg+zVAeRQ4qbaMmWp9vb9889CFA8JECH7lkwCL6Ygg8kA==",
"dev": true
}
}

View File

@ -104,7 +104,7 @@
},
"devDependencies": {
"blockbench-types": "^3.9.0",
"electron": "^13.3.0",
"electron": "^13.5.1",
"electron-builder": "^22.14.4",
"electron-notarize": "^1.0.0",
"webpack": "^5.21.2",