-
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.
Parameters:
-
loopCallback
: Your main draw loop function, it will receive the parameters loopCallback(timer
,gl
) for a CubicVR.Timer and the WebGL Context. -
doClear
(optional) : Whether or not to callgl.clear( DEPTH_BUFFER | COLOR_BUFFER )
before each frame, default:true
.
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) {
// ...
});
Set the Timer to paused or unpaused state.
Parameters:
-
state
:true
to pause,false
to unpause.
Returns:
none
Get the Timer paused state.
Returns:
true
if paused, false
if not.
Set the Timer to a specific time, in Seconds.
Parameters:
-
timerSeconds
: The new time in Seconds.
Returns:
none
Get the current time position from the timer in Seconds.
Returns:
Timer position in Seconds.
Reset the Timer to 0.
Returns:
none