I have been working on rotating a cube around a sphere in my project. When I press the spacebar, the cube begins to rotate around the sphere as intended. However, I am facing an issue where the rotation is much faster than expected. I created a function that calculates the rotation using an "angle" parameter. Initially, I thought a full rotation from 0 to 359 degrees would be necessary, but surprisingly, the cube completes a full rotation around the sphere when the angle increases by just 7 degrees.
Here is the relevant code snippet excluding the setup of cube and sphere meshes:
var rotationAngle = 0;
function rotate(angle)
{
// Rotation logic for cube position around the sphere
}
In the above code, "whiteBall" represents the sphere, and "keu" represents the cube.
Within my render function, I increment the angle and call the rotate function to apply the rotation:
if(isKeyPressed)
{
if(rotationAngle < 360)
{
rotationAngle += 1;
}
if(rotationAngle == 360)
rotationAngle = 0;
}
rotate(rotationAngle);
I am puzzled as to why such a small increase like 7 degrees results in a complete rotation of the cube around the sphere. Any suggestions or code snippets to rectify this behavior would be greatly appreciated.