playAnimation method

Future<void> playAnimation()

Starts playing the model's animation(s).

If the model contains multiple animations they play in sequence. Has no effect if the model has no animations.

Implementation

Future<void> playAnimation() async {
  unawaited(webViewController?.runJavaScript('''
    const viewer = document.querySelector('model-viewer');
    if (viewer && viewer.availableAnimations && viewer.availableAnimations.length > 0) {
      viewer.play();
    }
  '''));
}