2016-09-28 38 views
0

有沒有辦法以更漂亮的方式重用相同的動畫?如何在A幀中重用動畫?

<a-entity channel-selection class="channels" mixin="fontplane" material="opacity:0.6"> 
    <a-animation attribute="material.opacity" begin="fade" to="0"></a-animation> 
    <a-animation attribute="material.opacity" begin="unfade" to="0.6"></a-animation> 
    <a-entity class="channels" mixin="channelfont" text="text: Channel6"> 
    <a-animation attribute="material.opacity" begin="fade" to="0"></a-animation> 
    <a-animation attribute="material.opacity" begin="unfade" to="0.6"></a-animation> 
    </a-entity> 
</a-entity> 

回答

0

有幾種方法。

一:您可以在動畫使用混入:

<a-mixin id="fade" attribute="material.opacity" begin="fade" to="0"></a-mixin> 
<a-mixin id="fade" attribute="material.opacity" begin="unfade" to="0.6"></a-mixin> 
<a-entity channel-selection class="channels" mixin="fontplane" material="opacity:0.6"> 
     <a-animation mixin="fade"></a-animation> 
     <a-animation mixin="unfade"></a-animation> 

     <a-entity class="channels" mixin="channelfont" text="text: Channel6"> 
     <a-animation mixin="fade"></a-animation> 
     <a-animation mixin="unfade"></a-animation> 
     </a-entity> 
    </a-entity> 

另外還有animation component with mixinsaframe-mss (mixin stylesheet format),但不幸的是有關於混入與可以有多個實例的組件的一些錯誤。

二:template component可以工作了

<head> 
    <title>My A-Frame Scene</title> 
    <script src="https://aframe.io/releases/0.3.0/aframe.min.js"></script> 
    <script src="https://unpkg.com/ngokevin/aframe-template-component/dist/aframe-template-component.min.js"></script> 
</head> 

<body> 
    <a-scene> 
    <a-assets> 
     <script id="fadeAnimations" type="text/html"> 
     <a-animation></a-animation> 
     <a-animation></a-animation> 
     </script> 
    </a-assets> 

    <a-entity template="src: #fadeAnimations"> 
     <a-entity template="src: #fadeAnimations"></a-entity> 
    </a-entity> 
    </a-scene>