-
Notifications
You must be signed in to change notification settings - Fork 103
MainLoop
The MainLoop provides a simple way to wrap your main drawing loop. It also provides a CubicVR.Timer as well as the WebGL Context as two parameters to your callback respectively. MainLoop will use the window.*requestAnimationFrame() methods to manage framerate where available and fallback to setInterval() otherwise.
### _MainLoop( loopCallback, doClear )_ **Parameters**: *loopCallback* - Your main draw loop function, it will recieve the parameters _loopCallback( timer, gl )_ for a CubicVR.Timer and the WebGL Context. *doClear* - Whether or not to call gl.clear( DEPTH_BUFFER | COLOR_BUFFER ) before each frame. **Returns**: if called with ` new MainLoop(..) ` will return a MainLoop instance, none if used as singleton. **Typical Usage**:
var myloop = new CubicVR.MainLoop(function (timer,gl) {
// ...
});
or
CubicVR.MainLoop(function (timer,gl) {
// ...
});
Purpose:
Set the timer to paused or unpaused state.
Parameters:
state - true to pause, false to unpause.
Returns:
none.
Purpose:
Get the timer to paused state.
Returns:
true if paused, false if not.
Purpose:
Set the timer to a specific time, in Seconds.
Parameters:
timerSeconds - The new time in Seconds.
Returns:
none.
Purpose:
Get the current time position from the timer in Seconds.
Returns:
Timer posision in Seconds.
Purpose:
Reset the timer to 0.
Returns:
none.