mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-01-18 15:26:19 +08:00
Fix #1860 playback of loop modes in anim controllers
Fix error when saving timeline setup Support "context.is_first_person" for attachables
This commit is contained in:
parent
da328a0751
commit
680db62587
@ -477,7 +477,13 @@ class Animation extends AnimationItem {
|
||||
}
|
||||
}
|
||||
get time() {
|
||||
return (this.length && this.loop === 'loop') ? ((Timeline.time - 0.001) % this.length) + 0.001 : Timeline.time;
|
||||
if (!this.length || this.loop == 'once') {
|
||||
return Timeline.time;
|
||||
} else if (this.loop === 'loop') {
|
||||
return ((Timeline.time - 0.001) % this.length) + 0.001;
|
||||
} else if (this.loop === 'hold') {
|
||||
return Math.min(Timeline.time, this.length);
|
||||
}
|
||||
}
|
||||
createUniqueName(arr) {
|
||||
var scope = this;
|
||||
@ -1116,6 +1122,9 @@ const Animator = {
|
||||
if (!node.constructor.animator) return;
|
||||
Animator.resetLastValues();
|
||||
animations.forEach(animation => {
|
||||
if (animation.loop == 'once' && Timeline.time > animation.length && animation.length) {
|
||||
return;
|
||||
}
|
||||
let multiplier = animation.blend_weight ? Math.clamp(Animator.MolangParser.parse(animation.blend_weight), 0, Infinity) : 1;
|
||||
if (typeof controller_blend_values[animation.uuid] == 'number') multiplier *= controller_blend_values[animation.uuid];
|
||||
animation.getBoneAnimator(node).displayFrame(multiplier);
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
Animator.MolangParser.context = {};
|
||||
Animator.MolangParser.global_variables = {
|
||||
'true': 1,
|
||||
'false': 0,
|
||||
@ -8,7 +8,7 @@ Animator.MolangParser.global_variables = {
|
||||
return Math.clamp(time, 0, 0.1);
|
||||
},
|
||||
get 'query.anim_time'() {
|
||||
return Animation.selected ? Animation.selected.time : Timeline.time;
|
||||
return Animator.MolangParser.context.animation ? Animator.MolangParser.context.animation.time : Timeline.time;
|
||||
},
|
||||
get 'query.life_time'() {
|
||||
return Timeline.time;
|
||||
@ -69,6 +69,9 @@ Animator.MolangParser.global_variables = {
|
||||
get 'query.is_first_person'() {
|
||||
return Project.bedrock_animation_mode == 'attachable_first' ? 1 : 0;
|
||||
},
|
||||
get 'context.is_first_person'() {
|
||||
return Project.bedrock_animation_mode == 'attachable_first' ? 1 : 0;
|
||||
},
|
||||
get 'time'() {
|
||||
return Timeline.time;
|
||||
}
|
||||
|
@ -444,6 +444,7 @@ class BoneAnimator extends GeneralAnimator {
|
||||
displayFrame(multiplier = 1) {
|
||||
if (!this.doRender()) return;
|
||||
this.getGroup()
|
||||
Animator.MolangParser.context.animation = this.animation;
|
||||
|
||||
if (!this.muted.rotation) this.displayRotation(this.interpolate('rotation'), multiplier)
|
||||
if (!this.muted.position) this.displayPosition(this.interpolate('position'), multiplier)
|
||||
|
@ -202,7 +202,7 @@ const Blockbench = {
|
||||
text: {full_width: true, placeholder, value}
|
||||
},
|
||||
onConfirm({text}) {
|
||||
callback(text);
|
||||
if (callback) callback(text);
|
||||
resolve(text);
|
||||
},
|
||||
onOpen() {
|
||||
|
@ -301,6 +301,7 @@ class ModelProject {
|
||||
if (TextureAnimator.isPlaying) TextureAnimator.stop();
|
||||
this.selected = false;
|
||||
Painter.current = {};
|
||||
Animator.MolangParser.context = {};
|
||||
scene.remove(this.model_3d);
|
||||
OutlinerNode.uuids = {};
|
||||
Format = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user