Skip to content

Playing GLTF animation with start and end time #80

Answered by jnsmalm
goldenratio asked this question in Q&A
Discussion options

You must be logged in to vote

It's not built in, but you can create this function yourself.

function playAnimationClip(animation, fromTime, endTime, loop) {
  animation.position = fromTime
  let ticker = new PIXI.Ticker()
  ticker.add(() => {
    animation.position += ticker.deltaMS / 1000
    if (animation.position < endTime) {
      return
    }
    if (loop) {
      if (animation.position > endTime) {
        animation.position = fromTime
      }
    }
    else {
      animation.position = endTime
    }
  })
  ticker.start()
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@goldenratio
Comment options

Answer selected by goldenratio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants