简体   繁体   中英

How to enable animations for 3D models in A-frame?

I have a simple code, I load a 3D model and I want to attach it some animation to move from A point to B point. But I don't know what is missing.... This animation even don't start...

    <a-scene>
        <a-assets>

        <a-asset-item id="cowlowpoly" src="cow2/lowpolycow/cow.obj"></a-asset-item>
        </a-assets>

        <a-entity obj-model="obj: #cowlowpoly;" scale="0.001 0.001 0.001"   rotation="0.0 -90 0.0" position="0.0 0.0 -2.0">
          <a-animation attribute="position" dur="3000" from="0.0 0.0 -2.0" to="0.0 0.0 -20.0" repeat="indefinite">
          </a-animation>
        </a-entity>
  </a-scene>

Try something like this

        <a-entity obj-model="obj: #cowlowpoly;"
                  scale="0.001 0.001 0.001"
                  rotation="0.0 -90 0.0"
                  position="0.0 0.0 -2.0"
                  animation="property: position;
                             dur: 3000;
                             from: 0.0 0.0 -2.0;
                             to: 0.0 0.0 -20.0;
                             loop: true">
        </a-entity>

The script <a-animation></a-animation> is outdated and is not reliable, even though many the online tutorials use it (mainly because they are old tutorials).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM