mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-18 15:26:19 +08:00
Keyframe fixes
This commit is contained in:
parent
03f6a726fb
commit
d461fcef23
@ -684,6 +684,11 @@
|
||||
margin-left: -3px;
|
||||
pointer-events: none;
|
||||
}
|
||||
#timeline_body .keyframe i.keyframe_icon_smaller {
|
||||
font-size: 11pt;
|
||||
margin-top: 4px;
|
||||
margin-left: -1px;
|
||||
}
|
||||
#timeline_body .animator_head_bar .keyframe {
|
||||
z-index: 1;
|
||||
}
|
||||
|
@ -890,7 +890,8 @@
|
||||
:title="tl('timeline.'+keyframe.channel)"
|
||||
@contextmenu.prevent="keyframe.showContextMenu($event)"
|
||||
>
|
||||
<i class="material-icons">{{ keyframe.interpolation == 'catmullrom' ? 'lens' : 'stop' }}</i>
|
||||
<i class="material-icons keyframe_icon_smaller" v-if="keyframe.interpolation == 'catmullrom'">lens</i>
|
||||
<i class="material-icons" v-else>stop</i>
|
||||
<svg class="keyframe_waveform" v-if="keyframe.channel == 'sound' && keyframe.file && waveforms[keyframe.file]" :style="{width: waveforms[keyframe.file].duration * size}">
|
||||
<polygon :points="getWaveformPoints(waveforms[keyframe.file].samples, size)"></polygon>
|
||||
</svg>
|
||||
|
@ -769,21 +769,23 @@ class BoneAnimator extends GeneralAnimator {
|
||||
|
||||
if (values instanceof Array) {
|
||||
keyframe.extend({
|
||||
x: values[0],
|
||||
y: values[1],
|
||||
z: values[2]
|
||||
data_points: [{
|
||||
x: values[0],
|
||||
y: values[1],
|
||||
z: values[2]
|
||||
}]
|
||||
})
|
||||
if (values[3]) {
|
||||
keyframe.extend({w: values[3], isQuaternion: true})
|
||||
}
|
||||
} else if (typeof values === 'number' || typeof values === 'string') {
|
||||
keyframe.extend({
|
||||
x: values,
|
||||
y: values,
|
||||
z: values
|
||||
data_points: [{
|
||||
x: values,
|
||||
y: values,
|
||||
z: values
|
||||
}]
|
||||
})
|
||||
} else if (values == null) {
|
||||
var ref = this.interpolate(keyframe.channel, allow_expression)
|
||||
console.log(ref)
|
||||
if (ref) {
|
||||
let e = 1e2
|
||||
ref.forEach((r, i) => {
|
||||
@ -792,11 +794,11 @@ class BoneAnimator extends GeneralAnimator {
|
||||
}
|
||||
})
|
||||
keyframe.extend({
|
||||
x: ref[0],
|
||||
y: ref[1],
|
||||
z: ref[2],
|
||||
w: ref.length === 4 ? ref[3] : undefined,
|
||||
isQuaternion: ref.length === 4
|
||||
data_points: [{
|
||||
x: ref[0],
|
||||
y: ref[1],
|
||||
z: ref[2],
|
||||
}]
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@ -879,9 +881,9 @@ class BoneAnimator extends GeneralAnimator {
|
||||
//
|
||||
} else {
|
||||
let no_interpolations = Blockbench.hasFlag('no_interpolations')
|
||||
let alpha = Math.lerp(before.time, after.time, time)
|
||||
|
||||
if (no_interpolations || (before.interpolation == Keyframe.interpolation.linear && after.interpolation == Keyframe.interpolation.linear)) {
|
||||
let alpha = Math.lerp(before.time, after.time, time)
|
||||
if (no_interpolations) {
|
||||
alpha = Math.round(alpha)
|
||||
}
|
||||
@ -898,9 +900,9 @@ class BoneAnimator extends GeneralAnimator {
|
||||
let after_plus = sorted[before_index+2];
|
||||
|
||||
result = [
|
||||
before.getCatmullromLerp(before_plus, before, after, after_plus, 'x'),
|
||||
before.getCatmullromLerp(before_plus, before, after, after_plus, 'y'),
|
||||
before.getCatmullromLerp(before_plus, before, after, after_plus, 'z'),
|
||||
before.getCatmullromLerp(before_plus, before, after, after_plus, 'x', alpha),
|
||||
before.getCatmullromLerp(before_plus, before, after, after_plus, 'y', alpha),
|
||||
before.getCatmullromLerp(before_plus, before, after, after_plus, 'z', alpha),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class Keyframe {
|
||||
return calc + (other.calc(axis, other_data_point) - calc) * amount;
|
||||
}
|
||||
}
|
||||
getCatmullromLerp(before_plus, before, after, after_plus, axis) {
|
||||
getCatmullromLerp(before_plus, before, after, after_plus, axis, alpha) {
|
||||
var vectors = [];
|
||||
|
||||
if (before_plus) vectors.push(new THREE.Vector2(before_plus.time, before_plus.calc(axis, 0)))
|
||||
@ -182,7 +182,7 @@ class Keyframe {
|
||||
if (after_plus) vectors.push(new THREE.Vector2(after_plus.time, after_plus.calc(axis, 0)))
|
||||
|
||||
var curve = new THREE.SplineCurve(vectors);
|
||||
let time = Math.lerp(vectors[0].x, vectors.last().x, Timeline.time)
|
||||
let time = (alpha + (before_plus ? 1 : 0)) / (vectors.length-1);
|
||||
|
||||
return curve.getPoint(time).y;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user