mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-03-19 17:01:55 +08:00
Add support for mc bedrock material instances
This commit is contained in:
parent
1b4a96e55c
commit
9205ddac23
@ -344,6 +344,7 @@ function calculateVisibleBox() {
|
||||
var face = base_cube.faces[key]
|
||||
if (s.uv[key]) {
|
||||
face.extend({
|
||||
material_name: s.uv[key].material_instance,
|
||||
uv: [
|
||||
s.uv[key].uv[0],
|
||||
s.uv[key].uv[1]
|
||||
@ -532,6 +533,9 @@ function calculateVisibleBox() {
|
||||
face.uv_size[1],
|
||||
]
|
||||
});
|
||||
if (face.material_name) {
|
||||
template.uv[key].material_instance = face.material_name;
|
||||
}
|
||||
if (key == 'up' || key == 'down') {
|
||||
template.uv[key].uv[0] += template.uv[key].uv_size[0];
|
||||
template.uv[key].uv[1] += template.uv[key].uv_size[1];
|
||||
|
@ -85,6 +85,7 @@ class Face {
|
||||
new Property(Face, 'number', 'rotation', {default: 0});
|
||||
new Property(Face, 'number', 'tint', {default: -1});
|
||||
new Property(Face, 'string', 'cullface', {merge_validation: (val) => (uv_dialog.allFaces.includes(val) || val == '')});
|
||||
new Property(Face, 'string', 'material_name');
|
||||
new Property(Face, 'boolean', 'enabled', {default: true});
|
||||
|
||||
Face.opposite = {
|
||||
@ -799,6 +800,7 @@ class Cube extends NonGroup {
|
||||
})
|
||||
return arr;
|
||||
}},
|
||||
'edit_material_instances',
|
||||
'toggle_visibility',
|
||||
'delete'
|
||||
]);
|
||||
@ -865,4 +867,47 @@ BARS.defineActions(function() {
|
||||
return base_cube
|
||||
}
|
||||
})
|
||||
|
||||
new Action({
|
||||
id: 'edit_material_instances',
|
||||
icon: 'fas.fa-adjust',
|
||||
category: 'edit',
|
||||
condition: {modes: ['edit'], formats: ['bedrock'], method: () => !Project.box_uv && Cube.selected.length},
|
||||
click: function () {
|
||||
let form = {};
|
||||
|
||||
let first = Cube.selected[0];
|
||||
for (var key in first.faces) {
|
||||
let face = first.faces[key];
|
||||
if (face.texture != null) {
|
||||
form[key] = {
|
||||
label: `face.${key}`,
|
||||
value: face.material_name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let dialog = new Dialog({
|
||||
id: 'material_instances',
|
||||
title: 'dialog.material_instances.title',
|
||||
width: 460,
|
||||
form,
|
||||
onConfirm: form_data => {
|
||||
dialog.hide();
|
||||
|
||||
Undo.initEdit({elements: Cube.selected});
|
||||
Cube.selected.forEach(cube => {
|
||||
for (var key in cube.faces) {
|
||||
let face = cube.faces[key];
|
||||
if (face.texture != null && typeof form_data[key] == 'string') {
|
||||
face.material_name = form_data[key];
|
||||
}
|
||||
}
|
||||
})
|
||||
Undo.finishEdit('edit material instances')
|
||||
}
|
||||
})
|
||||
dialog.show();
|
||||
}
|
||||
})
|
||||
})
|
@ -290,6 +290,8 @@
|
||||
"dialog.scale.confirm": "Scale",
|
||||
"dialog.scale.select_overflow": "Select Overflow",
|
||||
|
||||
"dialog.material_instances.title": "Material Instances",
|
||||
|
||||
"dialog.plugins.title": "Plugins",
|
||||
"dialog.plugins.installed": "Installed",
|
||||
"dialog.plugins.available": "Available",
|
||||
@ -831,6 +833,8 @@
|
||||
"action.rename.desc": "Change the name of the selected cubes",
|
||||
"action.update_autouv": "Update Auto UV",
|
||||
"action.update_autouv.desc": "Update the auto UV mapping of the selected cubes",
|
||||
"action.edit_material_instances": "Edit Material Instances",
|
||||
"action.edit_material_instances.desc": "Edit material instance names for bedrock block geometries",
|
||||
|
||||
"action.add_display_preset": "New Preset",
|
||||
"action.add_display_preset.desc": "Add a new display setting preset",
|
||||
|
Loading…
x
Reference in New Issue
Block a user