Implement transparency render order option

This commit is contained in:
JannisX11 2023-07-19 22:58:06 +02:00
parent 4348e776e7
commit ba9bdc73e8
4 changed files with 44 additions and 0 deletions

View File

@ -916,6 +916,7 @@ class Cube extends OutlinerElement {
return arr;
}},
'edit_material_instances',
'element_render_order',
new MenuSeparator('manage'),
'rename',
'toggle_visibility',
@ -934,6 +935,7 @@ new Property(Cube, 'string', 'name', {default: 'cube'});
new Property(Cube, 'boolean', 'box_uv', {merge_validation: (value) => Format.optional_box_uv || value === Format.box_uv});
new Property(Cube, 'boolean', 'rescale');
new Property(Cube, 'boolean', 'locked');
new Property(Cube, 'enum', 'render_order', {default: 'default', values: ['default', 'behind', 'in_front']});
OutlinerElement.registerType(Cube, 'cube');
@ -982,6 +984,7 @@ new NodePreviewController(Cube, {
this.updateGeometry(element);
this.updateFaces(element);
this.updateUV(element);
this.updateRenderOrder(element);
this.dispatchEvent('setup', {element});
},
@ -1465,4 +1468,31 @@ BARS.defineActions(function() {
BarItems.cube_uv_mode.set(Cube.selected[0].box_uv ? 'box_uv' : 'face_uv');
}
})
new BarSelect('element_render_order', {
name: 'action.element_render_order',
category: 'edit',
condition: () => Outliner.selected.find(e => e.render_order) && Texture.all.length,
options: {
default: 'action.element_render_order.default',
behind: 'action.element_render_order.behind',
in_front: 'action.element_render_order.in_front',
},
onChange() {
let elements = Outliner.selected.filter(e => e.render_order);
Undo.initEdit({elements});
elements.forEach(element => {
element.render_order = this.value;
element.preview_controller.updateRenderOrder(element);
})
Undo.finishEdit('Change render order')
updateSelection();
}
})
Blockbench.on('update_selection', () => {
let element = Outliner.selected.find(e => e.render_order);
if (element) {
BarItems.element_render_order.set(element.render_order);
}
})
})

View File

@ -806,6 +806,7 @@ class Mesh extends OutlinerElement {
})
return arr;
}},
'element_render_order',
new MenuSeparator('manage'),
'rename',
'toggle_visibility',
@ -823,6 +824,7 @@ new Property(Mesh, 'vector', 'origin');
new Property(Mesh, 'vector', 'rotation');
new Property(Mesh, 'boolean', 'visibility', {default: true});
new Property(Mesh, 'boolean', 'locked');
new Property(Mesh, 'enum', 'render_order', {default: 'default', values: ['default', 'behind', 'in_front']});
OutlinerElement.registerType(Mesh, 'mesh');
@ -860,6 +862,7 @@ new NodePreviewController(Mesh, {
this.updateGeometry(element);
this.updateFaces(element);
this.updateUV(element);
this.updateRenderOrder(element);
mesh.visible = element.visibility;
this.dispatchEvent('setup', {element});

View File

@ -644,6 +644,13 @@ class NodePreviewController extends EventSystem {
this.dispatchEvent('update_selection', {element});
}
updateRenderOrder(element) {
switch (element.render_order) {
case 'behind': element.mesh.renderOrder = -1; break;
case 'in_front': element.mesh.renderOrder = 1; break;
default: element.mesh.renderOrder = 0; break;
}
}
}
/**
Standardied outliner node context menu group order

View File

@ -1303,6 +1303,10 @@
"action.unfold_groups.desc": "Unfold all groups in the outliner",
"action.edit_bedrock_binding": "Edit Binding...",
"action.edit_bedrock_binding.desc": "Change which bone the geometry is bound to",
"action.element_render_order": "Transparency Render Order",
"action.element_render_order.default": "Auto",
"action.element_render_order.behind": "Behind",
"action.element_render_order.in_front": "In Front",
"action.slider_color_h": "Hue",
"action.slider_color_s": "Saturation",