Search code examples
aframegetelementbyidsetattributeaabb

Failed to execute 'setAttribute' on Element


I am getting this error using A-frame VR v0.9.2 "Uncaught DOMException: Failed to execute 'setAttribute' on Element: 0 is not a valid attribute name." when trying to set an invisible entity as visible using Kevin Ngo's aabb-collider component.

  <!DOCTYPE html>
<html>
  <head>
    <script src=".../aframe-v0.9.2.min.js"></script>
    <script src=".../aframe-extras.min.js"></script>
    <script src=".../aframe-event-set-component.js"></script>
    <script src="...aframe-aabb-collider-component.min.js"></script>
  </head>
  <body>
    <a-scene>
       <a-assets>
        <a-asset-item
          id="modelo"
          response-type="arraybuffer"
          src=".../model.glb">
        </a-asset-item>
      </a-assets>
      <a-entity
    id="3Dmodelo"
        gltf-model="#modelo"
        scale="1  1  1"
        position="-16.7 0 -7.8"
        visible="false">
      </a-entity>
       <a-entity
        id="rig"
        position="-5.481 -0.15 13"
        rotation="0 0 0"
        movement-controls="speed: 0.08"  
        aabb-collider="objects: a-box">
         <a-entity 
          camera
      geometry="primitive: box"
          position="0 1.6 0"
          look-controls="pointerLockEnabled: false">
     </a-entity>
    </a-entity>
      <a-box id="testeColisao" color="red" position="-5 1 10" event-set__hitstart="modeloVisivel()"></a-box>
    </a-scene>
    <script type="text/javascript">
        function modeloVisivel(){
        document.getElementById('3Dmodelo').setAttribute('visible','true')
        }
    </script>
  </body>
  </html>

Can anyone help me please as i am struggling with the resolution of this issue. If anyone knows a better aproach for the intended please share.

Thank you.


Solution

  • change event-set__hitstart attribute to

    event-set__hitstart="_target: #blackSofa; visible: false"

    Here is event-set component's documentation https://github.com/supermedium/superframe/tree/master/components/event-set

    According to it you can't set function names