feat: add startOffset parameter to gltf playAnimation
This commit is contained in:
@@ -129,7 +129,7 @@ namespace thermion_filament
|
||||
void resetBones(EntityId entityId);
|
||||
bool setTransform(EntityId entityId, math::mat4f transform);
|
||||
bool updateBoneMatrices(EntityId entityId);
|
||||
void playAnimation(EntityId e, int index, bool loop, bool reverse, bool replaceActive, float crossfade = 0.3f);
|
||||
void playAnimation(EntityId e, int index, bool loop, bool reverse, bool replaceActive, float crossfade = 0.3f, float startOffset = 0.0f);
|
||||
void stopAnimation(EntityId e, int index);
|
||||
void setMorphTargetWeights(const char *const entityName, float *weights, int count);
|
||||
void loadTexture(EntityId entity, const char *resourcePath, int renderableIndex);
|
||||
|
||||
@@ -168,7 +168,7 @@ extern "C"
|
||||
int skinIndex,
|
||||
int boneIndex,
|
||||
const float *const transform);
|
||||
EMSCRIPTEN_KEEPALIVE void play_animation(void *sceneManager, EntityId entity, int index, bool loop, bool reverse, bool replaceActive, float crossfade);
|
||||
EMSCRIPTEN_KEEPALIVE void play_animation(void *sceneManager, EntityId entity, int index, bool loop, bool reverse, bool replaceActive, float crossfade, float startOffset);
|
||||
EMSCRIPTEN_KEEPALIVE void set_animation_frame(void *sceneManager, EntityId entity, int animationIndex, int animationFrame);
|
||||
EMSCRIPTEN_KEEPALIVE void stop_animation(void *sceneManager, EntityId entity, int index);
|
||||
EMSCRIPTEN_KEEPALIVE int get_animation_count(void *sceneManager, EntityId asset);
|
||||
|
||||
@@ -78,8 +78,6 @@ extern "C"
|
||||
const char *const entityName,
|
||||
float *const weights,
|
||||
int count);
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void play_animation_ffi(void *const sceneManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade);
|
||||
EMSCRIPTEN_KEEPALIVE void set_animation_frame_ffi(void *const sceneManager, EntityId asset, int animationIndex, int animationFrame);
|
||||
EMSCRIPTEN_KEEPALIVE void stop_animation_ffi(void *const sceneManager, EntityId asset, int index);
|
||||
EMSCRIPTEN_KEEPALIVE void get_animation_count_ffi(void *const sceneManager, EntityId asset, void (*callback)(int));
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user