Nathaniel Sena
Nathaniel Sena

Reputation: 11

How to return current rotation of Aframe entity

This code worked for me once but does no longer. I am trying to figure out how to rotate an entity the wraps a few elements in a scene.

 var entityEl = document.querySelector('#rotate');
    console.log(entityEl.components);//returns components object
    var entityRotY = entityEl.components.rotation.attrValue.y;//rotation is undefined

    function rotate(){
        entityEl.setAttribute('rotation', {x: 0, y: entityRotX + 1, z: 0});
        entityRotY++;
    }

Upvotes: 1

Views: 617

Answers (1)

Piotr Adam Milewski
Piotr Adam Milewski

Reputation: 14645

Although your method seems to be working, I'm not sure if messing with the attrValue is a proper way.

Instead try getAttribute('rotation') or entityEl.object3D.rotation (radian output!)

Upvotes: 2

Related Questions