Skip to content

Commit

Permalink
Implement #1024 Mesh stats on status bar
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JannisX11 committed Oct 8, 2021
1 parent 5da83af commit feaafd7
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 14 deletions.
3 changes: 3 additions & 0 deletions css/window.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions js/blockbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions js/interface/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down
42 changes: 42 additions & 0 deletions js/interface/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ onVueSetup(function() {
Prop,
isMobile: Blockbench.isMobile,
streamer_mode: settings.streamer_mode.value,
selection_info: '',
Format: null
},
methods: {
Expand All @@ -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
},
Expand All @@ -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>
Expand Down
1 change: 1 addition & 0 deletions js/interface/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion js/io/formats/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions js/texturing/textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
})
Expand Down
1 change: 1 addition & 0 deletions js/texturing/uv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion js/webpack/bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit feaafd7

Please sign in to comment.