mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-18 15:26:19 +08:00
Apply mesh rotation feature
This commit is contained in:
parent
8c707525f2
commit
f70d7da324
@ -253,6 +253,7 @@ const MenuBar = {
|
||||
'switch_face_crease',
|
||||
'merge_vertices',
|
||||
'dissolve_edges',
|
||||
'apply_mesh_rotation',
|
||||
'split_mesh',
|
||||
'merge_meshes',
|
||||
]},
|
||||
|
@ -799,6 +799,26 @@ BARS.defineActions(function() {
|
||||
Undo.finishEdit('Convert cubes to meshes', {elements: new_meshes, outliner: true});
|
||||
}
|
||||
})
|
||||
new Action('apply_mesh_rotation', {
|
||||
icon: 'published_with_changes',
|
||||
category: 'edit',
|
||||
condition: {modes: ['edit'], features: ['meshes'], method: () => (Mesh.selected.length)},
|
||||
click() {
|
||||
let vec = new THREE.Vector3();
|
||||
Undo.initEdit({elements: Mesh.selected});
|
||||
Mesh.selected.forEach(mesh => {
|
||||
let rotation = mesh.mesh.rotation;
|
||||
for (let vkey in mesh.vertices) {
|
||||
vec.fromArray(mesh.vertices[vkey]);
|
||||
vec.applyEuler(rotation);
|
||||
mesh.vertices[vkey].V3_set(vec.x, vec.y, vec.z);
|
||||
}
|
||||
mesh.rotation.V3_set(0, 0, 0);
|
||||
})
|
||||
Undo.finishEdit('Apply mesh rotation')
|
||||
Canvas.updateView({elements: Mesh.selected, element_aspects: {geometry: true, transform: true}, selection: true})
|
||||
}
|
||||
})
|
||||
new Action('invert_face', {
|
||||
icon: 'flip_to_back',
|
||||
category: 'edit',
|
||||
|
@ -773,6 +773,7 @@ class Mesh extends OutlinerElement {
|
||||
'switch_face_crease',
|
||||
'merge_vertices',
|
||||
'dissolve_edges',
|
||||
'apply_mesh_rotation',
|
||||
new MenuSeparator('mesh_combination'),
|
||||
'split_mesh',
|
||||
'merge_meshes',
|
||||
|
@ -1400,6 +1400,8 @@
|
||||
"action.create_face.desc": "Creates a new face or edge between the selected vertices",
|
||||
"action.convert_to_mesh": "Convert to Mesh",
|
||||
"action.convert_to_mesh.desc": "Convert the selected elements into meshes",
|
||||
"action.apply_mesh_rotation": "Apply Rotation",
|
||||
"action.apply_mesh_rotation.desc": "Reset the element rotation of the mesh, any apply it to the geometry instead",
|
||||
"action.invert_face": "Invert Face",
|
||||
"action.invert_face.desc": "Invert the selected faces to make them face the opposite direction",
|
||||
"action.switch_face_crease": "Switch Face Crease",
|
||||
|
Loading…
Reference in New Issue
Block a user