Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/shapecraft. flo-bit.dev/shapecraft
Something went wrong. Try again.
767 B · 53 lines
JavaScript
at commit da69385e
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354function WebGLAnimation() {
let context = null; let isAnimating = false; let animationLoop = null; let requestId = null;
function onAnimationFrame( time, frame ) {
animationLoop( time, frame );
requestId = context.requestAnimationFrame( onAnimationFrame );
}
return {
start: function () {
if ( isAnimating === true ) return; if ( animationLoop === null ) return;
requestId = context.requestAnimationFrame( onAnimationFrame );
isAnimating = true;
},
stop: function () {
context.cancelAnimationFrame( requestId );
isAnimating = false;
},
setAnimationLoop: function ( callback ) {
animationLoop = callback;
},
setContext: function ( value ) {
context = value;
}
};
}
export { WebGLAnimation };