mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Add auto keyframe feature
This commit is contained in:
parent
536bd974dc
commit
2d618f776a
@ -92,14 +92,22 @@ class GeneralAnimator {
|
||||
getOrMakeKeyframe(channel) {
|
||||
let before, result;
|
||||
let epsilon = Timeline.getStep()/2 || 0.01;
|
||||
let has_before = false;
|
||||
|
||||
for (let kf of this[channel]) {
|
||||
if (Math.abs(kf.time - Timeline.time) <= epsilon) {
|
||||
before = kf;
|
||||
}
|
||||
if (kf.time < Timeline.time) {
|
||||
has_before = true;
|
||||
}
|
||||
}
|
||||
result = before ? before : this.createKeyframe(null, Timeline.time, channel, false, false);
|
||||
return {before, result};
|
||||
let new_keyframe;
|
||||
if (settings.auto_keyframe.value && !before && !has_before) {
|
||||
new_keyframe = this.createKeyframe({}, 0, channel, false, false);
|
||||
}
|
||||
return {before, result, new_keyframe};
|
||||
}
|
||||
showContextMenu(event) {
|
||||
Prop.active_panel = 'timeline'
|
||||
|
@ -460,6 +460,7 @@ const Settings = {
|
||||
'mesh_selection': tl('menu.paste.mesh_selection'),
|
||||
}});
|
||||
new Setting('stretch_linked', {category: 'edit', value: true});
|
||||
new Setting('auto_keyframe', {category: 'edit', value: true});
|
||||
|
||||
//Grid
|
||||
new Setting('grids', {category: 'grid', value: true, onChange() {Canvas.buildGrid()}});
|
||||
|
@ -1161,11 +1161,12 @@
|
||||
var animator = Animation.selected.getBoneAnimator();
|
||||
if (animator) {
|
||||
|
||||
var {before, result} = animator.getOrMakeKeyframe(Toolbox.selected.animation_channel);
|
||||
var {before, result, new_keyframe} = animator.getOrMakeKeyframe(Toolbox.selected.animation_channel);
|
||||
|
||||
Undo.initEdit({keyframes: before ? [before] : []})
|
||||
result.select();
|
||||
scope.keyframes.push(result);
|
||||
if (new_keyframe) scope.keyframes.push(new_keyframe)
|
||||
}
|
||||
|
||||
} else if (Modes.id === 'display') {
|
||||
|
@ -855,6 +855,8 @@
|
||||
"settings.only_selected_bezier_handles.desc": "Hide handles of bézier keyframes that are not currently selected",
|
||||
"settings.stretch_linked": "Link Stretching",
|
||||
"settings.stretch_linked.desc": "Stretch the cube in all directions with the same value",
|
||||
"settings.auto_keyframe": "Auto Keyframe",
|
||||
"settings.auto_keyframe.desc": "Automatically create a keyframe with default values at the timeline start when transforming the bone at a later point",
|
||||
|
||||
"settings.grids": "Show Grids",
|
||||
"settings.grids.desc": "Show or hide all 3D grids",
|
||||
|
Loading…
Reference in New Issue
Block a user