obj缩放与A框库悬停

问题描述:

我正在学习如何使用Javascript和A框架库,我试图改变一个obj模型的规模,而徘徊在它上面。obj缩放与A框库悬停

我正在关注Building with Components教程,但是我的代码有些问题,它似乎不适用于我。

这里是我的代码

<a-scene> 
     <a-assets> 
      <audio id="click-sound" src="audioclick.mp3"></audio> 
      <a-asset-item id="e45-obj" src="E45.obj"></a-asset-item> 
      <a-asset-item id="e45-mtl" src="E45.mtl"></a-asset-item> 

      <script id="link" type="text/nunjucks"> 
       <a-entity class="link" 
          sound="on: click; src: #click-sound" 
          event-set__1="_event: mousedown; scale: .5 .5 .5" 
          event-set__2="_event: mouseup; scale: 0.8 0.8 0.5" 
          event-set__3="_event: mouseenter; scale: 0.8 0.8 0.5" 
          event-set__4="_event: mouseleave; scale: .5 .5 .5"></a-entity> 
      </script> 
     </a-assets> 
     <a-entity template="src: #link"> 
     <a-obj-model scale=".5 .5 .5" rotation="0 -45 -45" position="0 1.5 -5" src="#e45-obj" mtl="#e45-mtl"> 
      <a-animation attribute="position" to="0 2.2 -5" direction="alternate" dur="2000" 
         repeat="indefinite"></a-animation> 
     </a-obj-model></a-entity> 
    </a-scene> 

提前感谢!

+0

你是什么意思?看起来你不能用包含'template'属性的元素来包装实体。 –

+0

在本教程中,实体使用模板,通过将其悬停在实体上进行扩展。我不能用obj-model做同样的事情,我不知道为什么。 –

+0

其实,当你在一个元素上附加'template'组件时,模板将在文档准备好后被延迟加载。装载之后,该元件将成为' A-OBJ-模型> ',因此,该''元件没有'事件集合'组件。 –

<a-obj-model event-set__scale="_event: mouseenter; scale: 2 2 2"></a-obj-model>

+0

谢谢!但为什么我不能像使用实体一样使用obj模板? –