I want to copy the roation around the y (up) axis of an object (spawnpoint) that is facing the camera and assign this rotation to an other object (myEntity).
I set the rotation of the toolSpawnpoint to camera rotation like this: spawnpoint.setRotation(camera.getRotation());
And getting the y rotation of the spawnpoint with this: toolSpawnpoint.getEulerAngles().y;
I assign this rotation to another object myEntity: myEntity.setEulerAngles(0.0, spawnpoint.getEulerAngles().y, 0.0);
My problem now is, that I get an angle between -90 and +90 degree. The rotation angle increases till +90° and then decreases until it reaces -90° again. So for 180° my rotation is correct and after this first 180° myEntity starts to rotate in the opposite direction for the next 180°.
Why is this happening and how can I fix it? I dont’t get that at the moment.
Not sure exactly what your intention is but it sounds like using the entity.lookAt function would be a better fit here.
An entity’s rotation can be represented in multiple different combinations of eular angles. The engine doesn’t store the rotation of an entity as eular angles but rather in a transformation matrix and the eular angles are calculated hence not getting the expected value on a single axis. The values on the other two axes also matter, even for simple rotation around the Y axis.
What should happen:
When the user clicks on a panel: Working: 1) picker-raycast.js animates the camera position to pickedEntity child position, just in front of the pickedEntity. Working: 2) picker-raycast.js sends zero vertical rotation to camera-look.js as Ex. PROBLEM: 3) picker-raycast.js sends pickedEntity rotation to camera-look.js as Ey.
So I could manage to get the camera moving to the desired position, rotating up or down, but could not get the camera to animate its rotation towards the panels.
The main problem is that the camera-look.js is controlling the camera rotation. There are a number of ways to handle this and I’m going to give you the most direct route which doesn’t give you a smooth transition of rotation. It will just ‘snap’ to the correct rotation.
As the camera and target entities are all at the same height and we are planning on looking at them straight on, it does make this a lot easier.
You had the right idea on changing the targetEX/Y on the camera look script.