| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- function 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 };
|