2016-08-03 15 views

答えて

3

A-Frame Template Componentをご覧ください。特にSwapping Exampleです。

スクリプトタグ内または別のファイル内で別々のシーンを定義することができます。ここではスクリプトタグのテンプレートと例です:あなたは、あなたのシーンを変更したいとき

<a-scene> 
    <!-- Templates. --> 
    <a-assets> 
    <script id="scene1" type="text/html"> 
     <a-box></a-box> 
    </script> 
    <script id="scene2" type="text/html"> 
     <a-sphere></a-sphere> 
    </script> 
    </a-assets> 

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

はその後、srcを変更:

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

ここでは、プログラムの間隔でテンプレートsrcを変更するには、例えば、コンポーネントさ:https://github.com/ngokevin/aframe-template-component/blob/master/examples/swapping/components/template-looper.js

主それはCの他の構成要素についてel.setAttribute('template', 'src', '#sphere');

あろうSRCを変更する支援ウルド:

  • Event Set ComponentあなたのMouseEnterに耳を傾ける助けと反応してsrcを変更することができます。
  • テンプレートコンポーネントには、イベント時にテンプレートを変更するtemplate-setコンポーネントも付属しています。
+0

aframe-event-set-componentを使用してテンプレートsrc(ngokevin/aframe-template-componentから)を変更することはできますか? – user2267386

+0

ええ、私もあなたもできるはずです。提供された 'template-set'コンポーネントは、イベントに応答してテンプレートを変更することもできます。 – ngokevin

+0

ありがとうございました。 – user2267386

関連する問題