2016-09-28 1 views
0

Existe-t-il un moyen de réutiliser la même animation d'une manière plus jolie?Comment réutiliser des animations dans A-Frame?

<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> 

Répondre

0

Il y a plusieurs façons.

One: vous pouvez utiliser mixins sur une animation:

<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> 

Il y a aussi le animation component with mixins ou aframe-mss (mixin stylesheet format), mais malheureusement, il y a quelques bugs liés à mixins avec des composants qui peuvent avoir plusieurs instances.

Deux: le template component peut travailler trop

<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>