使用事件集组件和模板组件时不显示文本

时间:2018-07-17 11:10:03

标签: aframe webvr

我正在使用A-frame template组件和event set component制作具有多个场景的webvr,以监听鼠标输入/单击,从而改变我的src。

Here's 下方和下方的完整示例代码为index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Kingdom Animalia</title>
    <meta name="description" content="Belajar asyik dengan WebVR"></meta>
    <script src="https://cdn.glitch.com/a40a8a20-2b6c-4579-a653-7b641753965e%2Fbuild.js?1531824946222"></script>
    <script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
    <script src="aframe-event-set-component.js"></script>

  </head>

  <body>
    <a-scene>

     <a-assets>
        <img id="cnidaria" src="https://cdn.glitch.com/1f690faa-4dea-4828-a14a-c8fc529e9e2d%2F492542401-56a5f70d5f9b58b7d0df4ff5.jpg?1531237316164">
        <img id="porifera" src="https://cdn.glitch.com/1f690faa-4dea-4828-a14a-c8fc529e9e2d%2FPHYLUM%20PORIFERA%20_thumb%5B6%5D.jpg?1531237318597">
        <img id="annelida" src="https://cdn.glitch.com/1f690faa-4dea-4828-a14a-c8fc529e9e2d%2Fearthworm.jpg?1531237319615">
        <img id="planaria" src="https://cdn.glitch.com/1f690faa-4dea-4828-a14a-c8fc529e9e2d%2Fmaxresdefault.jpg?1531237360227">
        <img id="mollusca" src="https://cdn.glitch.com/1f690faa-4dea-4828-a14a-c8fc529e9e2d%2F802806388.jpg?1531237319128">
        <img id="ctenophora" src="https://cdn.glitch.com/1f690faa-4dea-4828-a14a-c8fc529e9e2d%2FRedLine1.jpg?1531237316608">
      </a-assets>

      <a-entity id="ganti" template="src: main.html"
                position="0 0 0">
      </a-entity>


      <a-sky id="mask" color="#111" opacity="0" radius="2">
        <a-animation attribute="material.opacity" begin="fade" from="0" to="1" dur="200"
                     direction="alternate" repeat="1"></a-animation>
      </a-sky>
    </a-scene>


  </body>
</html>

在main.html下面

 <a-entity
        position="-1 3 -3"
        geometry="primitive: plane; width: 8; height: auto"
        material="color: #0000FF"
        text="color: white; align: center; font: https://cdn.aframe.io/fonts/DejaVu-sdf.fnt;
              value: a-plane align:center (anchor:align) DejaVu width 8 1234567890123456789012345678901234567890">
      </a-entity>

      <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
      <a-sphere 
      event-set__click="_target: #ganti; template: src: boxes.html" 
      position="0 1.25 -5" radius="1.25" color="#000000" shadow></a-sphere>
      <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D" shadow></a-cylinder>
      <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" shadow></a-plane>
      <a-sky color="#c69b9b"></a-sky>


    <a-camera>
        <a-cursor id="cursor" position="0 0 0" color= "#efdf02"></a-cursor>
      </a-camera>

到目前为止,我可以在场景中显示img,框,球等,但是它根本不显示任何文本。我尝试了很多不同类型的文本。文本仍显示在其他代码中,这些代码未使用模板和事件集组件,但在我的示例中将不会显示。我该如何解决?

1 个答案:

答案 0 :(得分:1)

您的包含是错误的,首先包含template组件,然后包含core,然后是event组件。

如果先加载核心,则文本将显示在a-plane

查看here