0

ねえ、

私はこのプランカーを持っています: http://plnkr.co/edit/bKzi6rU3lIXT4Nz2wkR8?p=info

    <!DOCTYPE html>

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="stilovi/main.css">
  <title>Testing</title>
</head>

<body>
  <div id="avengers"></div>
</body>
<script src="snap.svg-min.js"></script>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://rawgit.com/julianshapiro/velocity/master/velocity.min.js"></script>
<script>
  function fetchXML(url, callback) {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', url, true);
    xhr.onreadystatechange = function(evt) {
      //Do not explicitly handle errors, those should be
      //visible via console output in the browser.
      if (xhr.readyState === 4) {
        callback(xhr.responseXML);
      }
    };
    xhr.send(null);
  };

  /*var list = ["test3.svg","test.2svg"];*/
  //fetch the document
  fetchXML("test3.svg", function(newSVGDoc) {
    //import it into the current DOM
    var n = document.importNode(newSVGDoc.documentElement, true);
    document.getElementById("avengers").appendChild(n);

    var ironman = document.getElementsByTagName("polygon");

    var ironmanlist = Array.prototype.slice.call(ironman);
    /*alert(ironmanlist.length);*/
    ironmanlist.forEach(function(elem, i) {
      /*for (var index = 0; index < elem.points.length; ++index){
                    //2.test case morphing each point (not working)//
                    console.log(elem.points[index]);
                    $.Velocity(elem.points[index],{x:100,y:100},{duration:Math.floor(Math.random() * (3000 - 1000 + 1)) + 1000}, "ease-in-out");
                    //3.test case morphing each point in another way (not working)//
                    /*$(elem.points[index])
                        .velocity({x:100,y:100},{duration:Math.floor(Math.random() * (3000 - 1000 + 1)) + 1000}, "ease-in-out");
                    console.log(elem.points[index]);
                }*/
      //1. working test case (translation)//
      console.log(elem.points[0].x);
      $.Velocity(elem, {
        translateX: -300
      }, {
        duration: Math.floor(Math.random() * (3000 - 1000 + 1)) + 1000
      }, "ease-in-out");
      //$.Velocity(elem,{rotateZ:"45deg"},{duration:Math.floor(Math.random() * (3000 - 1000 + 1)) + 1000}, "ease-in-out");
      console.log(elem.points[0].x);
      //End of 1. working test case//
    });
    console.log(ironmanlist);


  });
</script>

</html>

私のコードといくつかの例。私がやりたいことは、ある SVG 画像の各ポリゴンを別の SVG 画像の別のポリゴンにモーフィングすることです。翻訳は機能しますが、モーフのやり方がわかりません。誰かが助けたり、コードをチェックして、私が間違っていることを教えてくれますか? 多くのポリゴンがあり、高速である必要があるため、velocity.js を使用しました。

また、すべてを three.js に移行して、three.js で使用するのに最適な形式に変換することも考えていました。しかし、それをsvgとして使用して優れたパフォーマンスを維持することが可能であれば、そうします。

4

1 に答える 1