mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-17 16:20:13 +08:00
Transform space update
Local transform space for pivot tool, closes #774 Add local transform space support for bones in edit & animations, closes #2205 Rename bone transform space to parent Change default transform space from local to parent
This commit is contained in:
parent
17ca7d67bd
commit
2c36755b2b
@ -2083,6 +2083,7 @@ const BARS = {
|
||||
children: [
|
||||
'transform_space',
|
||||
'rotation_space',
|
||||
'transform_pivot_space',
|
||||
'selection_mode',
|
||||
'animation_controller_preview_mode',
|
||||
'bedrock_animation_mode',
|
||||
|
@ -943,14 +943,14 @@ BARS.defineActions(function() {
|
||||
new BarSelect('transform_space', {
|
||||
condition: {
|
||||
modes: ['edit', 'animate'],
|
||||
tools: ['move_tool', 'pivot_tool', 'resize_tool'],
|
||||
tools: ['move_tool', 'resize_tool'],
|
||||
method: () => !(Toolbox && Toolbox.selected.id === 'resize_tool' && Mesh.all.length === 0)
|
||||
},
|
||||
category: 'transform',
|
||||
value: 'local',
|
||||
value: 'parent',
|
||||
options: {
|
||||
global: true,
|
||||
bone: {condition: () => Format.bone_rig, name: true},
|
||||
parent: true,
|
||||
local: true,
|
||||
normal: {condition: () => Mesh.selected.length, name: true}
|
||||
},
|
||||
@ -961,16 +961,33 @@ BARS.defineActions(function() {
|
||||
new BarSelect('rotation_space', {
|
||||
condition: {modes: ['edit', 'animate', 'pose'], tools: ['rotate_tool']},
|
||||
category: 'transform',
|
||||
value: 'local',
|
||||
value: 'parent',
|
||||
options: {
|
||||
global: 'action.transform_space.global',
|
||||
bone: {condition: () => Format.bone_rig, name: true, name: 'action.transform_space.bone'},
|
||||
parent: 'action.transform_space.parent',
|
||||
local: 'action.transform_space.local'
|
||||
},
|
||||
onChange() {
|
||||
updateSelection();
|
||||
}
|
||||
})
|
||||
new BarSelect('transform_pivot_space', {
|
||||
condition: {
|
||||
modes: ['edit', 'animate'],
|
||||
tools: ['pivot_tool']
|
||||
},
|
||||
category: 'transform',
|
||||
value: 'parent',
|
||||
options: {
|
||||
global: 'action.transform_space.global',
|
||||
parent: 'action.transform_space.parent',
|
||||
local: 'action.transform_space.local',
|
||||
normal: {condition: () => Mesh.selected.length, name: true}
|
||||
},
|
||||
onChange() {
|
||||
updateSelection();
|
||||
}
|
||||
})
|
||||
new BarSelect('vertex_snap_mode', {
|
||||
options: {
|
||||
move: true,
|
||||
|
@ -825,11 +825,16 @@
|
||||
var rotation_tool = Toolbox.selected.id === 'rotate_tool' || Toolbox.selected.id === 'pivot_tool'
|
||||
if (!selected.length && (!Group.selected || !rotation_tool || !Format.bone_rig)) return;
|
||||
|
||||
let input_space = Toolbox.selected == BarItems.rotate_tool ? BarItems.rotation_space.get() : BarItems.transform_space.get()
|
||||
let input_space;
|
||||
switch (Toolbox.selected.id) {
|
||||
case 'rotate_tool': input_space = BarItems.rotation_space.get(); break;
|
||||
case 'pivot_tool': input_space = BarItems.transform_pivot_space.get(); break;
|
||||
case 'move_tool': default: input_space = BarItems.transform_space.get(); break;
|
||||
}
|
||||
|
||||
if (Toolbox.selected == BarItems.rotate_tool && Format.rotation_limit) return 2;
|
||||
|
||||
if (input_space == 'local' && selected.length && selected[0].rotatable && (!Format.bone_rig || !Group.selected) && Toolbox.selected.id !== 'pivot_tool') {
|
||||
if (input_space == 'local' && selected.length && selected[0].rotatable && (!Format.bone_rig || !Group.selected)) {
|
||||
let is_local = true;
|
||||
if (Format.bone_rig) {
|
||||
for (var el of selected) {
|
||||
@ -851,8 +856,8 @@
|
||||
}
|
||||
if (is_local) return 2;
|
||||
}
|
||||
if (input_space === 'local' && Format.bone_rig && Group.selected && Toolbox.selected == BarItems.rotate_tool) {
|
||||
// Local Space
|
||||
if (input_space === 'local' && Format.bone_rig && Group.selected) {
|
||||
// Group local Space
|
||||
return 2;
|
||||
}
|
||||
if (input_space === 'normal' && Mesh.selected.length) {
|
||||
@ -980,6 +985,9 @@
|
||||
} else if (Toolbox.selected.id === 'move_tool' && BarItems.transform_space.value === 'global') {
|
||||
delete Transformer.rotation_ref;
|
||||
|
||||
} else if (Toolbox.selected.id === 'move_tool' && BarItems.transform_space.value === 'local') {
|
||||
Transformer.rotation_ref = Group.selected.mesh;
|
||||
|
||||
} else if (Toolbox.selected.id == 'resize_tool' || (Toolbox.selected.id === 'rotate_tool' && BarItems.rotation_space.value !== 'global')) {
|
||||
Transformer.rotation_ref = Group.selected.mesh;
|
||||
|
||||
@ -1391,6 +1399,14 @@
|
||||
vec.applyQuaternion(rotation.invert());
|
||||
origin.V3_add(vec.x, vec.y, vec.z);
|
||||
|
||||
} else if (transform_space == 2) {
|
||||
let vec = new THREE.Vector3();
|
||||
var rotation = new THREE.Quaternion();
|
||||
rotation.copy(Transformer.rotation_object.mesh.quaternion);
|
||||
vec[axis] = difference;
|
||||
vec.applyQuaternion(rotation);
|
||||
origin.V3_add(vec.x, vec.y, vec.z);
|
||||
|
||||
} else {
|
||||
origin[axisNumber] += difference;
|
||||
}
|
||||
@ -1503,6 +1519,16 @@
|
||||
scope.keyframes[0].offset('x', -offset_vec.x);
|
||||
scope.keyframes[0].offset('y', offset_vec.y);
|
||||
scope.keyframes[0].offset('z', offset_vec.z);
|
||||
|
||||
} else if (Toolbox.selected.id === 'move_tool' && BarItems.transform_space.value === 'local') {
|
||||
|
||||
let offset_vec = new THREE.Vector3();
|
||||
offset_vec[axis] = difference;
|
||||
offset_vec.applyQuaternion(mesh.quaternion);
|
||||
|
||||
scope.keyframes[0].offset('x', -offset_vec.x);
|
||||
scope.keyframes[0].offset('y', offset_vec.y);
|
||||
scope.keyframes[0].offset('z', offset_vec.z);
|
||||
|
||||
} else if (Toolbox.selected.id === 'resize_tool' && axis == 'e') {
|
||||
|
||||
|
@ -1422,7 +1422,7 @@
|
||||
"action.transform_space": "Transform Space",
|
||||
"action.transform_space.desc": "Default transform space for elements and bones",
|
||||
"action.transform_space.global": "Global",
|
||||
"action.transform_space.bone": "Bone",
|
||||
"action.transform_space.parent": "Parent",
|
||||
"action.transform_space.local": "Local",
|
||||
"action.transform_space.normal": "Normal",
|
||||
"action.rotation_space": "Rotation Space",
|
||||
|
Loading…
Reference in New Issue
Block a user