My goal is to display a rotating cube with a consistent rotation speed across different machines. In order to achieve this, I calculate the timespan between each frame and use this elapsed value in the rotation process.
Here's the basic code snippet:
var elapsed = (timestamp - lastFrameTimestamp)/1000.0; // Issue with cube not showing up
However, when I use this calculated value, nothing appears on the screen. Surprisingly, there are no errors or warnings shown in the console. When I log the elapsed value to the console, it shows the correct number.
I experimented by setting the difference to a fixed value, like so:
var elapsed = 16.665487/1000.0;
The cube displays properly using this fixed value. I have created a jsFiddle for reference. I tested this issue in both Chrome and Firefox, but encountered the same problem in both browsers.
If anyone has any ideas or insights into what might be causing this issue, I would greatly appreciate the help!