mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-03-19 17:01:55 +08:00
Add motion trail lock
Improve scaling of motion trail points Fix issue with menus not being clickable
This commit is contained in:
parent
ddfa694127
commit
b540a1b9bd
@ -515,6 +515,7 @@
|
||||
margin-right: 8px;
|
||||
}
|
||||
.contextMenu li span {
|
||||
pointer-events: none;
|
||||
flex: 1 0 auto;
|
||||
}
|
||||
.contextMenu li.focused > .contextMenu.sub {
|
||||
|
@ -1163,6 +1163,7 @@ const Animator = {
|
||||
get selected() {return Animation.selected},
|
||||
MolangParser: new Molang(),
|
||||
motion_trail: new THREE.Object3D(),
|
||||
motion_trail_lock: false,
|
||||
join() {
|
||||
|
||||
if ((Format.id == 'bedrock' || Format.id == 'bedrock_old') && !BedrockEntityManager.initialized_animations) {
|
||||
@ -1230,7 +1231,11 @@ const Animator = {
|
||||
}
|
||||
}
|
||||
},
|
||||
showMotionTrail(target = Group.selected) {
|
||||
showMotionTrail(target) {
|
||||
if (!target) {
|
||||
target = Animator.motion_trail_lock && Group.all.find(g => g.uuid == Animator.motion_trail_lock);
|
||||
if (!target) target = Group.selected;
|
||||
}
|
||||
let animation = Animation.selected;
|
||||
let currentTime = Timeline.time;
|
||||
let step = Timeline.getStep();
|
||||
@ -1282,7 +1287,7 @@ const Animator = {
|
||||
})
|
||||
Animator.motion_trail.add(line);
|
||||
|
||||
let dot_geo = new THREE.OctahedronGeometry(0.2);
|
||||
let dot_geo = new THREE.OctahedronGeometry(0.25);
|
||||
let keyframe_geo = new THREE.OctahedronGeometry(1.0);
|
||||
let dot_material = new THREE.MeshBasicMaterial({color: gizmo_colors.outline});
|
||||
geometry.vertices.forEach((vertex, i) => {
|
||||
@ -1305,8 +1310,7 @@ const Animator = {
|
||||
Animator.motion_trail.children.forEach((object) => {
|
||||
if (object.isLine) return;
|
||||
var scaleVector = new THREE.Vector3();
|
||||
var scale = scaleVector.subVectors(object.position, Preview.selected.camera.position).length() / 500;
|
||||
scale = (Math.sqrt(scale)/3 + scale/1.4) * 4
|
||||
var scale = scaleVector.subVectors(object.position, Preview.selected.camera.position).length() / 86;
|
||||
if (Blockbench.isMobile) scale *= 4;
|
||||
object.scale.set(scale, scale, scale)
|
||||
})
|
||||
@ -1709,7 +1713,8 @@ BARS.defineActions(function() {
|
||||
new Action('ik_enabled', {
|
||||
icon: 'check_box_outline_blank',
|
||||
category: 'animation',
|
||||
click: function () {
|
||||
condition: () => Animator.open && Group.selected,
|
||||
click() {
|
||||
Group.selected.ik_enabled = !Group.selected.ik_enabled;
|
||||
updateNslideValues();
|
||||
Transformer.updateSelection();
|
||||
@ -1738,6 +1743,22 @@ BARS.defineActions(function() {
|
||||
Undo.finishEdit('move keyframes')
|
||||
}
|
||||
})
|
||||
|
||||
// Motion Trail
|
||||
new Action('lock_motion_trail', {
|
||||
icon: 'lock_open',
|
||||
category: 'animation',
|
||||
condition: () => Animator.open && Group.selected,
|
||||
click() {
|
||||
if (Animator.motion_trail_lock) {
|
||||
Animator.motion_trail_lock = false;
|
||||
Animator.showMotionTrail();
|
||||
} else if (Group.selected) {
|
||||
Animator.motion_trail_lock = Group.selected.uuid;
|
||||
}
|
||||
this.setIcon(Animator.motion_trail_lock ? 'lock' : 'lock_open');
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Interface.definePanels(function() {
|
||||
|
@ -1690,12 +1690,13 @@ const BARS = {
|
||||
id: 'main_tools',
|
||||
children: [
|
||||
'transform_space',
|
||||
'rotation_space'
|
||||
'rotation_space',
|
||||
'lock_motion_trail'
|
||||
]
|
||||
})
|
||||
// update 3.6
|
||||
if (!Toolbars.main_tools.children.includes(BarItems.rotation_space)) {
|
||||
Toolbars.main_tools.add(BarItems.rotation_space, -1)
|
||||
// update 3.7
|
||||
if (!Toolbars.main_tools.children.includes(BarItems.lock_motion_trail)) {
|
||||
Toolbars.main_tools.add(BarItems.lock_motion_trail, -1)
|
||||
}
|
||||
Toolbars.brush = new Toolbar({
|
||||
id: 'brush',
|
||||
|
@ -1019,6 +1019,8 @@
|
||||
"action.ik_enabled.desc": "Enable Inverse Kinematics for this bone",
|
||||
"action.slider_ik_chain_length": "IK Chain Length",
|
||||
"action.slider_ik_chain_length.desc": "Upwards length of the IK bone chain",
|
||||
"action.lock_motion_trail": "Lock Motion Trail",
|
||||
"action.lock_motion_trail.desc": "Lock the motion trail to the currently selected group",
|
||||
|
||||
"timeline.rotation": "Rotation",
|
||||
"timeline.position": "Position",
|
||||
|
Loading…
x
Reference in New Issue
Block a user