Skip to content

⬅️ Back to Table of Contents

📄 WebGLAnimation.js

📊 Analysis Summary

Metric Count
🔧 Functions 10
📊 Variables & Constants 4

📚 Table of Contents

🛠️ File Location:

📂 src/renderers/webgl/WebGLAnimation.js

Variables & Constants

Name Type Kind Value Exported
context any let/var null
isAnimating boolean let/var false
animationLoop any let/var null
requestId any let/var null

Functions

WebGLAnimation(): { start: () => void; stop: () => void; setAnimationLoop: (callback: any) => void; setContext: (value: any) => void; }

Returns: { start: () => void; stop: () => void; setAnimationLoop: (callback: any) => void; setContext: (value: any) => void; }

Calls:

  • animationLoop
  • context.requestAnimationFrame
  • context.cancelAnimationFrame
Code
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;

        }

    };

}

onAnimationFrame(time: any, frame: any): void

Parameters:

  • time any
  • frame any

Returns: void

Calls:

  • animationLoop
  • context.requestAnimationFrame
Code
function onAnimationFrame( time, frame ) {

        animationLoop( time, frame );

        requestId = context.requestAnimationFrame( onAnimationFrame );

    }

start(): void

Returns: void

Calls:

  • context.requestAnimationFrame
Code
function () {

            if ( isAnimating === true ) return;
            if ( animationLoop === null ) return;

            requestId = context.requestAnimationFrame( onAnimationFrame );

            isAnimating = true;

        }

stop(): void

Returns: void

Calls:

  • context.cancelAnimationFrame
Code
function () {

            context.cancelAnimationFrame( requestId );

            isAnimating = false;

        }

setAnimationLoop(callback: any): void

Parameters:

  • callback any

Returns: void

Code
function ( callback ) {

            animationLoop = callback;

        }

setContext(value: any): void

Parameters:

  • value any

Returns: void

Code
function ( value ) {

            context = value;

        }

start(): void

Returns: void

Calls:

  • context.requestAnimationFrame
Code
function () {

            if ( isAnimating === true ) return;
            if ( animationLoop === null ) return;

            requestId = context.requestAnimationFrame( onAnimationFrame );

            isAnimating = true;

        }

stop(): void

Returns: void

Calls:

  • context.cancelAnimationFrame
Code
function () {

            context.cancelAnimationFrame( requestId );

            isAnimating = false;

        }

setAnimationLoop(callback: any): void

Parameters:

  • callback any

Returns: void

Code
function ( callback ) {

            animationLoop = callback;

        }

setContext(value: any): void

Parameters:

  • value any

Returns: void

Code
function ( value ) {

            context = value;

        }