mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-17 16:20:13 +08:00
Add hasAny and hasSelected to improve performance
This commit is contained in:
parent
15ba9dc866
commit
c671fe68c2
@ -420,7 +420,7 @@ BARS.defineActions(function() {
|
||||
vertex: {name: true, icon: 'fiber_manual_record'},
|
||||
},
|
||||
icon_mode: true,
|
||||
condition: () => Modes.edit && Mesh.all.length,
|
||||
condition: () => Modes.edit && Mesh.hasAny(),
|
||||
onChange({value}) {
|
||||
if (value === previous_selection_mode) return;
|
||||
if (value === 'object') {
|
||||
@ -516,7 +516,7 @@ BARS.defineActions(function() {
|
||||
category: 'tools',
|
||||
selectElements: true,
|
||||
modes: ['edit'],
|
||||
condition: () => Modes.edit && Mesh.all.length,
|
||||
condition: () => Modes.edit && Mesh.hasAny(),
|
||||
onCanvasClick(data) {
|
||||
if (!seam_timeout) {
|
||||
seam_timeout = setTimeout(() => {
|
||||
@ -545,7 +545,7 @@ BARS.defineActions(function() {
|
||||
divide: true,
|
||||
join: true,
|
||||
},
|
||||
condition: () => Modes.edit && Mesh.all.length,
|
||||
condition: () => Modes.edit && Mesh.hasAny(),
|
||||
onChange({value}) {
|
||||
if (value == 'auto') value = null;
|
||||
Undo.initEdit({elements: Mesh.selected});
|
||||
|
@ -519,6 +519,12 @@ class OutlinerElement extends OutlinerNode {
|
||||
console.warn('You cannot modify this')
|
||||
}
|
||||
})
|
||||
OutlinerElement.hasAny = function() {
|
||||
return Outliner.elements.length > 0 && Outliner.elements.findIndex(element => element instanceof this) !== -1;
|
||||
}
|
||||
OutlinerElement.hasSelected = function() {
|
||||
return Outliner.selected.length > 0 && Outliner.selected.findIndex(element => element instanceof this) !== -1;
|
||||
}
|
||||
OutlinerElement.types = {};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user