mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fix 3D model animations when a negative time scale is used (#7474)
This commit is contained in:
@@ -285,7 +285,7 @@ namespace gdjs {
|
||||
|
||||
update(instanceContainer: gdjs.RuntimeInstanceContainer): void {
|
||||
const elapsedTime = this.getElapsedTime() / 1000;
|
||||
this._renderer.updateAnimation(elapsedTime * this._animationSpeedScale);
|
||||
this._renderer.updateAnimation(elapsedTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -383,6 +383,7 @@ namespace gdjs {
|
||||
|
||||
setAnimationSpeedScale(ratio: float): void {
|
||||
this._animationSpeedScale = ratio;
|
||||
this._renderer.setAnimationTimeScale(ratio);
|
||||
}
|
||||
|
||||
getAnimationElapsedTime(): float {
|
||||
|
@@ -371,15 +371,17 @@ namespace gdjs {
|
||||
}
|
||||
const previousAction = this._action;
|
||||
this._action = this._animationMixer.clipAction(clip);
|
||||
|
||||
// The action must be reset before being reconfigured with setLoop to prevent previous action parameters causing problems
|
||||
// such as animations not playing (not sure to which extends it can cause problems nor the origin of these problems)
|
||||
// Reset the animation and play it from the start.
|
||||
// `clipAction` always gives back the same action for a given animation
|
||||
// and its likely to be in a finished or at least started state.
|
||||
this._action.reset();
|
||||
this._action.setLoop(
|
||||
shouldLoop ? THREE.LoopRepeat : THREE.LoopOnce,
|
||||
Number.POSITIVE_INFINITY
|
||||
);
|
||||
this._action.clampWhenFinished = true;
|
||||
this._action.timeScale =
|
||||
this._model3DRuntimeObject.getAnimationSpeedScale();
|
||||
|
||||
if (previousAction && previousAction !== this._action) {
|
||||
this._action.crossFadeFrom(
|
||||
@@ -403,6 +405,12 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
|
||||
setAnimationTimeScale(timeScale: float): void {
|
||||
if (this._action) {
|
||||
this._action.timeScale = timeScale;
|
||||
}
|
||||
}
|
||||
|
||||
getAnimationDuration(animationName: string): float {
|
||||
const clip = THREE.AnimationClip.findByName(
|
||||
this._originalModel.animations,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"firstLayout": "",
|
||||
"gdVersion": {
|
||||
"build": 225,
|
||||
"build": 226,
|
||||
"major": 5,
|
||||
"minor": 5,
|
||||
"revision": 0
|
||||
@@ -3277,8 +3277,8 @@
|
||||
"BarRightPadding": 6,
|
||||
"BarBottomPadding": 6,
|
||||
"LabelMargin": 6,
|
||||
"MinValue": 0.25,
|
||||
"MaxValue": 4,
|
||||
"MinValue": -2,
|
||||
"MaxValue": 2,
|
||||
"InitialValue": 1,
|
||||
"StepSize": 0.125
|
||||
},
|
||||
@@ -5006,7 +5006,7 @@
|
||||
],
|
||||
"content": {
|
||||
"centerLocation": "ModelOrigin",
|
||||
"crossfadeDuration": 0,
|
||||
"crossfadeDuration": 0.5,
|
||||
"depth": 78,
|
||||
"height": 78,
|
||||
"keepAspectRatio": true,
|
||||
|
Reference in New Issue
Block a user