Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLAnimation: Convert to es6 class #20070

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions src/renderers/webgl/WebGLAnimation.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
function WebGLAnimation() {
class WebGLAnimation {

let context = null;
let isAnimating = false;
let animationLoop = null;
let requestId = null;
constructor() {

function onAnimationFrame( time, frame ) {
this._context = null;
this._isAnimating = false;
this._animationLoop = null;
this._requestId = null;

animationLoop( time, frame );

requestId = context.requestAnimationFrame( onAnimationFrame );
// Re-bind the prototype function so that `this` can be used with rAF:
this._onAnimationFrame = this._onAnimationFrame.bind( this );

}

return {
_onAnimationFrame( time, frame ) {

this._animationLoop( time, frame );

start: function () {
this._requestId = this._context.requestAnimationFrame( this._onAnimationFrame );

}

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

requestId = context.requestAnimationFrame( onAnimationFrame );
if ( this._isAnimating === true ) return;
if ( this._animationLoop === null ) return;

isAnimating = true;
this._requestId = this._context.requestAnimationFrame( this._onAnimationFrame );

},
this._isAnimating = true;

stop: function () {
}

context.cancelAnimationFrame( requestId );
stop() {

isAnimating = false;
this._context.cancelAnimationFrame( this._requestId );

},
this._isAnimating = false;

setAnimationLoop: function ( callback ) {
}

animationLoop = callback;
setAnimationLoop( callback ) {

},
this._animationLoop = callback;

setContext: function ( value ) {
}

context = value;
setContext( value ) {

}
this._context = value;

};
}

}

Expand Down