Skip to content

Commit

Permalink
Fix crash during animation (#553)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Shafran <[email protected]>
  • Loading branch information
ShafranIvan and Ivan Shafran authored Oct 19, 2024
1 parent 2b785cc commit 2969a2c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sceneview/src/main/java/io/github/sceneview/node/ModelNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ open class ModelNode(
}

private fun applyAnimations(frameTimeNanos: Long) {
playingAnimations.forEach { (index, animation) ->
if (animation.speed == 0f) return@forEach
val iterator = playingAnimations.iterator()
while (iterator.hasNext()) {
val (index, animation) = iterator.next()
if (animation.speed == 0f) continue

animator.let { animator ->
val elapsedTimeSeconds = frameTimeNanos.intervalSeconds(animation.startTime)
Expand All @@ -434,7 +436,7 @@ open class ModelNode(
animator.applyAnimation(index, animationTime)

if (!animation.loop && adjustedTimeSeconds >= animationDuration) {
playingAnimations.remove(index)
iterator.remove()
}
}
}
Expand Down

0 comments on commit 2969a2c

Please sign in to comment.