0
votes

I would like to remove the twoway-motion component from the entity player, and replace it with the progressive-controls component, using setAttribute.

While the removeAttribute works fine for removing the twoway-motion, the setAttribute does not add the progressive-controls.

<a-entity id="player" networked="template:#avatar-template;showLocalTemplate:false;" 
            camera spawn-in-circle="radius:3;" 
            position="0 1.3 0" 
            wasd-controls 
            look-controls 
            twoway-motion="speed: 35">

            <a-entity cursor="fuse: true; fuseTimeout: 500"
                position="0 0 -1"
                geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03"
                material="color: black; shader: flat"
                      id="defaultCursor">
            </a-entity>
  </a-entity>


<script> 
  var playerEl = document.getElementById('player');    
  var cursorEl = document.getElementById('defaultCursor');      

  playerEl.removeChild(cursorEl);

  playerEl.removeAttribute('twoway-motion'); 

  playerEl.setAttribute('progressive-controls');
 </script>
1

1 Answers

1
votes

the setAttribute(name, value) requires a value.

To add the component, just use setAttribute('progressive-controls', '') to add it with the default schema