2016-09-28 6 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)もありますが、残念ながら複数のインスタンスを持つことができるコンポーネントとミックスインに関連するいくつかのバグがあります。

2: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> 
すぎて作業することができます
関連する問題