mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-17 16:20:13 +08:00
UV Painter info bar
Improve mesh face deleting
This commit is contained in:
parent
4137963abf
commit
f169eb544d
@ -1284,6 +1284,16 @@
|
||||
.uv_mesh_vertex.selected {
|
||||
background-color: var(--color-accent);
|
||||
}
|
||||
.uv_painter_info {
|
||||
display: flex;
|
||||
}
|
||||
.uv_painter_info span {
|
||||
margin: 3px 6px;
|
||||
flex: 1 1 80px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
}
|
||||
/*
|
||||
#uv_size {
|
||||
height: 320px;
|
||||
|
@ -1502,12 +1502,16 @@ const BARS = {
|
||||
|
||||
Undo.initEdit({elements: Mesh.selected})
|
||||
|
||||
if (BarItems.selection_mode.value == 'face') {
|
||||
Mesh.selected.forEach(mesh => {
|
||||
Mesh.selected.forEach(mesh => {
|
||||
let has_selected_faces = false;
|
||||
for (let key in mesh.faces) {
|
||||
has_selected_faces = has_selected_faces || mesh.faces[key].isSelected();
|
||||
}
|
||||
if (BarItems.selection_mode.value == 'face' && has_selected_faces) {
|
||||
let selected_vertices = Project.selected_vertices[mesh.uuid];
|
||||
for (let key in mesh.faces) {
|
||||
let face = mesh.faces[key];
|
||||
if (!face.vertices.find(vertex_key => !selected_vertices.includes(vertex_key))) {
|
||||
if (face.isSelected()) {
|
||||
delete mesh.faces[key];
|
||||
}
|
||||
}
|
||||
@ -1521,9 +1525,7 @@ const BARS = {
|
||||
delete mesh.vertices[vertex_key];
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
Mesh.selected.forEach(mesh => {
|
||||
} else {
|
||||
let selected_vertices = Project.selected_vertices[mesh.uuid];
|
||||
selected_vertices.forEach(vertex_key => {
|
||||
delete mesh.vertices[vertex_key];
|
||||
@ -1538,8 +1540,8 @@ const BARS = {
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Undo.finishEdit('Delete mesh part')
|
||||
Canvas.updateView({elements: Mesh.selected, selection: true, element_aspects: {geometry: true, faces: true}})
|
||||
|
@ -133,9 +133,10 @@ class ModelFormat {
|
||||
})
|
||||
}
|
||||
|
||||
if (!Format.single_texture && old_format.single_texture && Texture.all.length == 1) {
|
||||
Cube.all.forEach(cube => {
|
||||
cube.applyTexture(Texture.all[0], true)
|
||||
if (!Format.single_texture && old_format.single_texture && Texture.all.length) {
|
||||
let texture = Textre.getDefault();
|
||||
Outliner.elements.filter(el => el.applyTexture).forEach(el => {
|
||||
el.applyTexture(texture, true)
|
||||
})
|
||||
}
|
||||
|
||||
@ -160,6 +161,13 @@ class ModelFormat {
|
||||
})
|
||||
}
|
||||
|
||||
//Texture Meshes
|
||||
if (!Format.texture_meshes && old_format.texture_meshes) {
|
||||
TextureMesh.all.slice().forEach(tm => {
|
||||
tm.remove()
|
||||
})
|
||||
}
|
||||
|
||||
//Canvas Limit
|
||||
if (Format.canvas_limit && !old_format.canvas_limit && !settings.deactivate_size_limit.value) {
|
||||
|
||||
|
@ -1608,6 +1608,7 @@ Interface.definePanels(function() {
|
||||
zoom: 1,
|
||||
checkerboard: settings.uv_checkerboard.value,
|
||||
texture: 0,
|
||||
mouse_coords: {x: -1, y: -1},
|
||||
|
||||
project_resolution: [16, 16],
|
||||
elements: [],
|
||||
@ -1692,6 +1693,22 @@ Interface.definePanels(function() {
|
||||
this.texture = UVEditor.texture = 0;
|
||||
}
|
||||
},
|
||||
updateMouseCoords(event) {
|
||||
convertTouchEvent(event);
|
||||
var pixel_size = this.inner_width / this.texture.width
|
||||
|
||||
if (Toolbox.selected.id === 'copy_paste_tool') {
|
||||
this.mouse_coords.x = Math.round(event.offsetX/pixel_size*1);
|
||||
this.mouse_coords.y = Math.round(event.offsetY/pixel_size*1);
|
||||
} else {
|
||||
let offset = BarItems.slider_brush_size.get()%2 == 0 && Toolbox.selected.brushTool ? 0.5 : 0;
|
||||
this.mouse_coords.x = Math.floor(event.offsetX/pixel_size*1 + offset);
|
||||
this.mouse_coords.y = Math.floor(event.offsetY/pixel_size*1 + offset);
|
||||
}
|
||||
if (this.texture.frameCount) {
|
||||
this.mouse_coords.y += (this.texture.height / this.texture.frameCount) * this.texture.currentFrame
|
||||
}
|
||||
},
|
||||
onMouseWheel(event) {
|
||||
if (event.ctrlOrCmd) {
|
||||
|
||||
@ -1713,7 +1730,9 @@ Interface.definePanels(function() {
|
||||
let zoom_diff = this.zoom - old_zoom;
|
||||
viewport.scrollLeft += ((viewport.scrollLeft + offsetX) * zoom_diff) / old_zoom
|
||||
viewport.scrollTop += ((viewport.scrollTop + offsetY) * zoom_diff) / old_zoom
|
||||
|
||||
|
||||
this.updateMouseCoords(event)
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -2050,6 +2069,8 @@ Interface.definePanels(function() {
|
||||
@mousedown="onMouseDown($event)"
|
||||
@touchstart="onMouseDown($event)"
|
||||
@mousewheel="onMouseWheel($event)"
|
||||
@mousemove="updateMouseCoords($event)"
|
||||
@mouseleave="if (mode == 'paint') mouse_coords.x = -1"
|
||||
class="checkerboard_target"
|
||||
ref="viewport"
|
||||
:style="{width: (width+8) + 'px', height: (height+8) + 'px', overflowX: (zoom > 1) ? 'scroll' : 'hidden', overflowY: (inner_height > height) ? 'scroll' : 'hidden'}"
|
||||
@ -2132,10 +2153,13 @@ Interface.definePanels(function() {
|
||||
|
||||
<div class="uv_transparent_face" v-else>${tl('uv_editor.transparent_face')}</div>
|
||||
</div>
|
||||
<div class="bar uv_editor_sliders" ref="slider_bar" style="margin-left: 2px;">
|
||||
</div>
|
||||
<div class="toolbar_wrapper uv_editor">
|
||||
<div v-show="mode == 'paint'" class="bar uv_painter_info">
|
||||
<span style="color: var(--color-subtle_text);">{{ mouse_coords.x < 0 ? '-' : (mouse_coords.x + ' ⨉ ' + mouse_coords.y) }}</span>
|
||||
<span v-if="texture">{{ texture.name }}</span>
|
||||
<span style="color: var(--color-subtle_text);">{{ Math.round(this.zoom*100).toString() + '%' }}</span>
|
||||
</div>
|
||||
<div v-show="mode == 'uv'" class="bar uv_editor_sliders" ref="slider_bar" style="margin-left: 2px;"></div>
|
||||
<div v-show="mode == 'uv'" class="toolbar_wrapper uv_editor"></div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user