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

text not displaying when using event-set-component and template- component

我正在制作具有多个场景的 webvr,使用 A-frame template component and event set component 来监听 mouseenter/click 所以它会改变我的 src。

Here's glitch 和下面的完整示例代码是 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、框、球体等,但它根本不显示任何文本。我试过很多不同类型的文字。文本仍然显示在其他不使用模板和事件集组件的代码中,但在我的示例中它不会显示。我该如何解决这个问题?

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

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

看看here