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;
|
width: 9px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
|
cursor: move;
|
||||||
}
|
}
|
||||||
.uv_mesh_vertex.selected {
|
.uv_mesh_vertex.selected {
|
||||||
background-color: var(--color-accent);
|
background-color: var(--color-accent);
|
||||||
|
@ -2389,7 +2389,7 @@ const BARS = {
|
|||||||
template: `
|
template: `
|
||||||
<dialog id="action_selector" v-if="open">
|
<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">
|
<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 v-if="search_type" class="action_selector_type_overlay">{{ search_type }}:</div>
|
||||||
<div id="action_selector_list">
|
<div id="action_selector_list">
|
||||||
<ul>
|
<ul>
|
||||||
@ -2499,17 +2499,35 @@ const ActionControl = {
|
|||||||
if (e.altKey) {
|
if (e.altKey) {
|
||||||
ActionControl.vue.$forceUpdate()
|
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) {
|
if (e.which === 38) {
|
||||||
data.index--;
|
data.index--;
|
||||||
if (data.index < 0) {
|
if (data.index < 0) {
|
||||||
data.index = data.length-1;
|
data.index = data.length-1;
|
||||||
}
|
}
|
||||||
|
updateScroll();
|
||||||
} else if (e.which === 40) {
|
} else if (e.which === 40) {
|
||||||
data.index++;
|
data.index++;
|
||||||
if (data.index >= data.length) {
|
if (data.index >= data.length) {
|
||||||
data.index = 0;
|
data.index = 0;
|
||||||
}
|
}
|
||||||
|
updateScroll();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,15 @@ window.BedrockEntityManager = class BedrockEntityManager {
|
|||||||
this.client_entity = this.getEntityFile();
|
this.client_entity = this.getEntityFile();
|
||||||
if (this.client_entity && this.client_entity.description) {
|
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
|
// Textures
|
||||||
var tex_list = this.client_entity.description.textures
|
var tex_list = this.client_entity.description.textures
|
||||||
if (tex_list instanceof Object) {
|
if (tex_list instanceof Object) {
|
||||||
@ -85,7 +94,7 @@ window.BedrockEntityManager = class BedrockEntityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (valid_textures_list.length == 1) {
|
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) {
|
} else if (valid_textures_list.length > 1) {
|
||||||
setTimeout(() => {this.project.whenNextOpen(() => {
|
setTimeout(() => {this.project.whenNextOpen(() => {
|
||||||
@ -105,11 +114,11 @@ window.BedrockEntityManager = class BedrockEntityManager {
|
|||||||
dialog.hide();
|
dialog.hide();
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
valid_textures_list.forEach(path => {
|
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) {
|
} else if (index == 0) {
|
||||||
selected_textures.forEach(i => {
|
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',
|
'create_face',
|
||||||
'invert_face',
|
'invert_face',
|
||||||
'_',
|
'_',
|
||||||
|
'merge_meshes',
|
||||||
'group_elements',
|
'group_elements',
|
||||||
'_',
|
'_',
|
||||||
'copy',
|
'copy',
|
||||||
@ -598,7 +599,8 @@ new NodePreviewController(Mesh, {
|
|||||||
|
|
||||||
for (let key in element.faces) {
|
for (let key in element.faces) {
|
||||||
let face = element.faces[key];
|
let face = element.faces[key];
|
||||||
|
if (face.vertices.length <= 2) continue;
|
||||||
|
|
||||||
face.vertices.forEach((key, i) => {
|
face.vertices.forEach((key, i) => {
|
||||||
uv_array.push(
|
uv_array.push(
|
||||||
((face.uv[key] ? face.uv[key][0] : 0) / Project.texture_width),
|
((face.uv[key] ? face.uv[key][0] : 0) / Project.texture_width),
|
||||||
@ -905,11 +907,9 @@ BARS.defineActions(function() {
|
|||||||
|
|
||||||
// Create Face between extruded line
|
// Create Face between extruded line
|
||||||
for (let fkey in mesh.faces) {
|
for (let fkey in mesh.faces) {
|
||||||
console.log(remaining_vertices.length);
|
|
||||||
if (remaining_vertices.length < 2) break;
|
if (remaining_vertices.length < 2) break;
|
||||||
let face = mesh.faces[fkey];
|
let face = mesh.faces[fkey];
|
||||||
let matched_vertices = face.vertices.filter(vkey => remaining_vertices.includes(new_vertices[original_vertices.indexOf(vkey)]));
|
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) {
|
if (matched_vertices.length >= 2) {
|
||||||
let [a, b] = matched_vertices.map(vkey => new_vertices[original_vertices.indexOf(vkey)]);
|
let [a, b] = matched_vertices.map(vkey => new_vertices[original_vertices.indexOf(vkey)]);
|
||||||
let [c, d] = matched_vertices;
|
let [c, d] = matched_vertices;
|
||||||
@ -1277,7 +1277,6 @@ BARS.defineActions(function() {
|
|||||||
} else if (!b) {
|
} else if (!b) {
|
||||||
b = vertex_keys[1];
|
b = vertex_keys[1];
|
||||||
}
|
}
|
||||||
console.log(a, b, m)
|
|
||||||
mesh.addFaces(new MeshFace( mesh, {vertices: [a, b, m]} ));
|
mesh.addFaces(new MeshFace( mesh, {vertices: [a, b, m]} ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,13 +127,12 @@ class Texture {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
var mat = new THREE.ShaderMaterial({
|
var mat = new THREE.ShaderMaterial({
|
||||||
uniforms: {
|
uniforms: {
|
||||||
map: {type: 't', value: tex},
|
map: {type: 't', value: tex},
|
||||||
SHADE: {type: 'bool', value: settings.shading.value},
|
SHADE: {type: 'bool', value: settings.shading.value},
|
||||||
BRIGHTNESS: {type: 'bool', value: settings.brightness.value / 50},
|
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,
|
vertexShader: vertShader,
|
||||||
fragmentShader: fragShader,
|
fragmentShader: fragShader,
|
||||||
|
@ -1559,7 +1559,7 @@ Interface.definePanels(function() {
|
|||||||
pos[1] = Math.round((e1.clientY - event.clientY) / step_y) / snap;
|
pos[1] = Math.round((e1.clientY - event.clientY) / step_y) / snap;
|
||||||
|
|
||||||
if (pos[0] != last_pos[0] || pos[1] != last_pos[1]) {
|
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);
|
last_pos.replace(pos);
|
||||||
UVEditor.displaySliders();
|
UVEditor.displaySliders();
|
||||||
UVEditor.loadData();
|
UVEditor.loadData();
|
||||||
@ -1682,7 +1682,7 @@ Interface.definePanels(function() {
|
|||||||
|
|
||||||
this.drag({
|
this.drag({
|
||||||
event,
|
event,
|
||||||
onDrag: (x, y) => {
|
onDrag: (x, y, event) => {
|
||||||
elements.forEach(element => {
|
elements.forEach(element => {
|
||||||
this.selected_faces.forEach(key => {
|
this.selected_faces.forEach(key => {
|
||||||
let face = element.faces[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)) {
|
if (this.selected_vertices[element.uuid] && this.selected_vertices[element.uuid].includes(vertex_key)) {
|
||||||
face.uv[vertex_key][0] += x;
|
face.uv[vertex_key][0] += x;
|
||||||
face.uv[vertex_key][1] += y;
|
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.mapAutoUV()
|
||||||
}
|
}
|
||||||
obj.preview_controller.updateTransform(obj);
|
obj.preview_controller.updateTransform(obj);
|
||||||
|
obj.preview_controller.updateGeometry(obj);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
TickUpdates.selection = true;
|
TickUpdates.selection = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user