feat: add startOffset parameter to gltf playAnimation

This commit is contained in:
Nick Fisher
2024-07-29 16:13:45 +08:00
parent 96ad9dee18
commit a30e2f295f
16 changed files with 29 additions and 62 deletions

View File

@@ -43,6 +43,7 @@ namespace thermion_filament
struct AnimationStatus
{
time_point_t start = time_point_t::max();
float startOffset;
bool loop = false;
bool reverse = false;
float durationInSecs = 0;
@@ -182,7 +183,7 @@ namespace thermion_filament
auto animationStatus = animationComponent.gltfAnimations[i];
auto elapsedInSecs = float(std::chrono::duration_cast<std::chrono::milliseconds>(now - animationStatus.start).count()) / 1000.0f;
auto elapsedInSecs = animationStatus.startOffset + float(std::chrono::duration_cast<std::chrono::milliseconds>(now - animationStatus.start).count()) / 1000.0f;
if (!animationStatus.loop && elapsedInSecs >= animationStatus.durationInSecs)
{