Search code examples
aframewebvr

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


i am making webvr with multiple scenes using A-frame template component and event set component to listen for mouseenter/click so it'll change my src.

Here's the full example code in glitch and below is the 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>

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

so far i can display img, boxes, spheres etc on the scenes, but it doesnt show any text at all. i've tried a lot of different kind of text. Text still showing up in other code which not using the template & event set component, but in my example it won't display. how can i fix this?


Solution

  • Your includes are wrong, first you include the template component, then the core, then the event component.

    If the core is loaded first, then the text is being displayed on the a-plane

    Check it out here