mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-18 15:26:19 +08:00
Improve action control interface
Fix mesh UV mapping preview issue Automatically import bedrock entity textures as emissive Use Shift key in UV editor to snap vertices to grid
This commit is contained in:
parent
1fba8753b1
commit
e7019b642d
@ -1277,6 +1277,7 @@
|
||||
width: 9px;
|
||||
background-color: white;
|
||||
border: 1px solid black;
|
||||
cursor: move;
|
||||
}
|
||||
.uv_mesh_vertex.selected {
|
||||
background-color: var(--color-accent);
|
||||
|
@ -2389,7 +2389,7 @@ const BARS = {
|
||||
template: `
|
||||
<dialog id="action_selector" v-if="open">
|
||||
<input type="text" v-model="search_input" @input="e => search_input = e.target.value" autocomplete="off" autosave="off" autocorrect="off" spellcheck="false" autocapitalize="off">
|
||||
<i class="material-icons" id="action_search_bar_icon">search</i>
|
||||
<i class="material-icons" id="action_search_bar_icon" @click="search_input = ''">{{ search_input ? 'clear' : 'search' }}</i>
|
||||
<div v-if="search_type" class="action_selector_type_overlay">{{ search_type }}:</div>
|
||||
<div id="action_selector_list">
|
||||
<ul>
|
||||
@ -2499,17 +2499,35 @@ const ActionControl = {
|
||||
if (e.altKey) {
|
||||
ActionControl.vue.$forceUpdate()
|
||||
}
|
||||
function updateScroll() {
|
||||
Vue.nextTick(() => {
|
||||
let list = document.querySelector('#action_selector_list ul');
|
||||
let node = list && list.children[data.index];
|
||||
if (!node) return;
|
||||
|
||||
var list_pos = $(list).offset().top;
|
||||
var el_pos = $(node).offset().top;
|
||||
|
||||
if (el_pos < list_pos) {
|
||||
list.scrollTop += el_pos - list_pos;
|
||||
} else if (el_pos > list.clientHeight + list_pos - 20) {
|
||||
list.scrollTop += el_pos - (list.clientHeight + list_pos) + 30;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (e.which === 38) {
|
||||
data.index--;
|
||||
if (data.index < 0) {
|
||||
data.index = data.length-1;
|
||||
}
|
||||
updateScroll();
|
||||
} else if (e.which === 40) {
|
||||
data.index++;
|
||||
if (data.index >= data.length) {
|
||||
data.index = 0;
|
||||
}
|
||||
updateScroll();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -68,6 +68,15 @@ window.BedrockEntityManager = class BedrockEntityManager {
|
||||
this.client_entity = this.getEntityFile();
|
||||
if (this.client_entity && this.client_entity.description) {
|
||||
|
||||
let render_mode;
|
||||
let {materials} = this.client_entity.description;
|
||||
if (materials) {
|
||||
let [key] = Object.keys(materials);
|
||||
if (typeof materials[key] == 'string' && materials[key].includes('emissive')) {
|
||||
render_mode = 'emissive'
|
||||
}
|
||||
}
|
||||
|
||||
// Textures
|
||||
var tex_list = this.client_entity.description.textures
|
||||
if (tex_list instanceof Object) {
|
||||
@ -85,7 +94,7 @@ window.BedrockEntityManager = class BedrockEntityManager {
|
||||
}
|
||||
}
|
||||
if (valid_textures_list.length == 1) {
|
||||
new Texture({keep_size: true}).fromPath(valid_textures_list[0]).add()
|
||||
new Texture({keep_size: true, render_mode}).fromPath(valid_textures_list[0]).add()
|
||||
|
||||
} else if (valid_textures_list.length > 1) {
|
||||
setTimeout(() => {this.project.whenNextOpen(() => {
|
||||
@ -105,11 +114,11 @@ window.BedrockEntityManager = class BedrockEntityManager {
|
||||
dialog.hide();
|
||||
if (index == 1) {
|
||||
valid_textures_list.forEach(path => {
|
||||
new Texture({keep_size: true}).fromPath(path).add()
|
||||
new Texture({keep_size: true, render_mode}).fromPath(path).add()
|
||||
})
|
||||
} else if (index == 0) {
|
||||
selected_textures.forEach(i => {
|
||||
new Texture({keep_size: true}).fromPath(valid_textures_list[i]).add()
|
||||
new Texture({keep_size: true, render_mode}).fromPath(valid_textures_list[i]).add()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -342,6 +342,7 @@ class Mesh extends OutlinerElement {
|
||||
'create_face',
|
||||
'invert_face',
|
||||
'_',
|
||||
'merge_meshes',
|
||||
'group_elements',
|
||||
'_',
|
||||
'copy',
|
||||
@ -598,7 +599,8 @@ new NodePreviewController(Mesh, {
|
||||
|
||||
for (let key in element.faces) {
|
||||
let face = element.faces[key];
|
||||
|
||||
if (face.vertices.length <= 2) continue;
|
||||
|
||||
face.vertices.forEach((key, i) => {
|
||||
uv_array.push(
|
||||
((face.uv[key] ? face.uv[key][0] : 0) / Project.texture_width),
|
||||
@ -905,11 +907,9 @@ BARS.defineActions(function() {
|
||||
|
||||
// Create Face between extruded line
|
||||
for (let fkey in mesh.faces) {
|
||||
console.log(remaining_vertices.length);
|
||||
if (remaining_vertices.length < 2) break;
|
||||
let face = mesh.faces[fkey];
|
||||
let matched_vertices = face.vertices.filter(vkey => remaining_vertices.includes(new_vertices[original_vertices.indexOf(vkey)]));
|
||||
console.log(matched_vertices);
|
||||
if (matched_vertices.length >= 2) {
|
||||
let [a, b] = matched_vertices.map(vkey => new_vertices[original_vertices.indexOf(vkey)]);
|
||||
let [c, d] = matched_vertices;
|
||||
@ -1277,7 +1277,6 @@ BARS.defineActions(function() {
|
||||
} else if (!b) {
|
||||
b = vertex_keys[1];
|
||||
}
|
||||
console.log(a, b, m)
|
||||
mesh.addFaces(new MeshFace( mesh, {vertices: [a, b, m]} ));
|
||||
}
|
||||
}
|
||||
|
@ -127,13 +127,12 @@ class Texture {
|
||||
|
||||
}
|
||||
}`
|
||||
|
||||
var mat = new THREE.ShaderMaterial({
|
||||
uniforms: {
|
||||
map: {type: 't', value: tex},
|
||||
SHADE: {type: 'bool', value: settings.shading.value},
|
||||
BRIGHTNESS: {type: 'bool', value: settings.brightness.value / 50},
|
||||
EMISSIVE: {type: 'bool', value: tex.render_mode == 'emissive'}
|
||||
EMISSIVE: {type: 'bool', value: this.render_mode == 'emissive'}
|
||||
},
|
||||
vertexShader: vertShader,
|
||||
fragmentShader: fragShader,
|
||||
|
@ -1559,7 +1559,7 @@ Interface.definePanels(function() {
|
||||
pos[1] = Math.round((e1.clientY - event.clientY) / step_y) / snap;
|
||||
|
||||
if (pos[0] != last_pos[0] || pos[1] != last_pos[1]) {
|
||||
onDrag(pos[0] - last_pos[0], pos[1] - last_pos[1])
|
||||
onDrag(pos[0] - last_pos[0], pos[1] - last_pos[1], e1)
|
||||
last_pos.replace(pos);
|
||||
UVEditor.displaySliders();
|
||||
UVEditor.loadData();
|
||||
@ -1682,7 +1682,7 @@ Interface.definePanels(function() {
|
||||
|
||||
this.drag({
|
||||
event,
|
||||
onDrag: (x, y) => {
|
||||
onDrag: (x, y, event) => {
|
||||
elements.forEach(element => {
|
||||
this.selected_faces.forEach(key => {
|
||||
let face = element.faces[key];
|
||||
@ -1690,6 +1690,11 @@ Interface.definePanels(function() {
|
||||
if (this.selected_vertices[element.uuid] && this.selected_vertices[element.uuid].includes(vertex_key)) {
|
||||
face.uv[vertex_key][0] += x;
|
||||
face.uv[vertex_key][1] += y;
|
||||
if ((event.shiftKey || Pressing.overrides.shift) && !(event.ctrlOrCmd || Pressing.overrides.ctrl)) {
|
||||
let multiplier = settings.shift_size.value / 16
|
||||
face.uv[vertex_key][0] = Math.round(face.uv[vertex_key][0] * multiplier) / multiplier;
|
||||
face.uv[vertex_key][1] = Math.round(face.uv[vertex_key][1] * multiplier) / multiplier;
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -961,6 +961,7 @@ BARS.defineActions(function() {
|
||||
obj.mapAutoUV()
|
||||
}
|
||||
obj.preview_controller.updateTransform(obj);
|
||||
obj.preview_controller.updateGeometry(obj);
|
||||
}
|
||||
})
|
||||
TickUpdates.selection = true;
|
||||
|
Loading…
Reference in New Issue
Block a user