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

@@ -1135,8 +1135,8 @@ namespace thermion_filament
return true;
}
void SceneManager::playAnimation(EntityId entityId, int index, bool loop, bool reverse, bool replaceActive, float crossfade)
void SceneManager::playAnimation(EntityId entityId, int index, bool loop, bool reverse, bool replaceActive, float crossfade, float startOffset)
{
std::lock_guard lock(_mutex);
@@ -1200,6 +1200,7 @@ namespace thermion_filament
}
GltfAnimation animation;
animation.startOffset = startOffset;
animation.index = index;
animation.start = std::chrono::high_resolution_clock::now();
animation.loop = loop;

View File

@@ -586,9 +586,10 @@ extern "C"
bool loop,
bool reverse,
bool replaceActive,
float crossfade)
float crossfade,
float startOffset)
{
((SceneManager *)sceneManager)->playAnimation(asset, index, loop, reverse, replaceActive, crossfade);
((SceneManager *)sceneManager)->playAnimation(asset, index, loop, reverse, replaceActive, crossfade, startOffset);
}
EMSCRIPTEN_KEEPALIVE void set_animation_frame(

View File

@@ -677,18 +677,6 @@ extern "C"
auto fut = _rl->add_task(lambda);
}
EMSCRIPTEN_KEEPALIVE void play_animation_ffi(void *const sceneManager,
EntityId asset, int index,
bool loop, bool reverse,
bool replaceActive,
float crossfade)
{
std::packaged_task<void()> lambda([=]
{ play_animation(sceneManager, asset, index, loop, reverse, replaceActive,
crossfade); });
auto fut = _rl->add_task(lambda);
}
EMSCRIPTEN_KEEPALIVE void set_animation_frame_ffi(void *const sceneManager,
EntityId asset,
int animationIndex,