[SOLVED] Set Euler Angles problem

Hello everyone,

I have a problem when setting an object to an specific angle rotation in one axis.

if (storageAvailable('localStorage')) {
        anguloInicialIntensity = localStorage.getItem('angle');
        console.log("init: " + localStorage.getItem('angle'));
        //this.entity.localEulerAngles().y = parseFloat(anguloInicial);
        //this.entity.rotate(90,localStorage.getItem('angle'),0);
        //this.entity.setEulerAngles(90,parseFloat(localStorage.getItem('angle')),0);
        this.entity.setEulerAngles(90,localStorage.getItem('angle'),0);
        console.log("x: " + this.entity.getEulerAngles().x + "an y: " + this.entity.getEulerAngles().y + "z: " + this.entity.getEulerAngles().z);

    }

i have tried this options but none of them work. As you can see in the following screenshot both .y and .z do what they want, instead of positioning where i told them to be:
imagen
(y should be equal to init. In this picture: y = 0.535)

I do not know what else to do

Thank you for your time!

The local storage keeps the number as a string type. When you do::

this.entity.setEulerAngles(90,localStorage.getItem('angle'),0);

that will use .setEulerAngles(number, string, number), which is not a correct syntax.

1 Like

Is there a correct way to do this?

Yes, the one that is commented out should be ok to use:

//this.entity.setEulerAngles(90,parseFloat(localStorage.getItem('angle')),0);

Parsing a string to get a number first, and then using it to set the angle is a correct way.

3 Likes

Tried that but did not work, that is why i commented it.
Btw I do not know how but now it does as i order it to do, so it is solved. Thank you a lot!

1 Like