  }

  async function createAnimation(elementName, keyframes) {
    const element = document.getElementById(elementName);
    const anim = element.animate(keyframes, 1000);
    anim.pause();
    anim.currentTime = 500;
    return anim.ready;
  }

  onload = async function() {
    await waitForNextFrame();

    await createAnimation('rotateAdd', [
        {rotate: '1 0 0 45deg', composite: 'add'},
        {rotate: '0 0 1 90deg'}]);
    await createAnimation('rotateReplace', [
        {rotate: '1 0 0 90deg'},