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

cancelAnimationFrame #51

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion dist/GlslCanvas.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ var GlslCanvas = function () {
this.uniforms = {};
this.vbo = {};
this.isValid = false;
this.animationFrameRequest = undefined;

this.BUFFER_COUNT = 0;
// this.TEXTURE_COUNT = 0;
Expand Down Expand Up @@ -1092,7 +1093,7 @@ var GlslCanvas = function () {
}

sandbox.render();
window.requestAnimationFrame(RenderLoop);
sandbox.animationFrameRequest = window.requestAnimationFrame(RenderLoop);
}

// Start
Expand All @@ -1104,6 +1105,9 @@ var GlslCanvas = function () {
createClass(GlslCanvas, [{
key: 'destroy',
value: function destroy() {
// Stop the animation
cancelAnimationFrame(this.animationFrameRequest);

this.animated = false;
this.isValid = false;
for (var tex in this.textures) {
Expand All @@ -1121,6 +1125,7 @@ var GlslCanvas = function () {
var buffer = this.buffers[key];
this.gl.deleteProgram(buffer.program);
}

this.program = null;
this.gl = null;
}
Expand Down
7 changes: 6 additions & 1 deletion dist/GlslCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ var GlslCanvas = function () {
this.uniforms = {};
this.vbo = {};
this.isValid = false;
this.animationFrameRequest = undefined;

this.BUFFER_COUNT = 0;
// this.TEXTURE_COUNT = 0;
Expand Down Expand Up @@ -1497,7 +1498,7 @@ var GlslCanvas = function () {
}

sandbox.render();
window.requestAnimationFrame(RenderLoop);
sandbox.animationFrameRequest = window.requestAnimationFrame(RenderLoop);
}

// Start
Expand All @@ -1509,6 +1510,9 @@ var GlslCanvas = function () {
createClass(GlslCanvas, [{
key: 'destroy',
value: function destroy() {
// Stop the animation
cancelAnimationFrame(this.animationFrameRequest);

this.animated = false;
this.isValid = false;
for (var tex in this.textures) {
Expand All @@ -1526,6 +1530,7 @@ var GlslCanvas = function () {
var buffer = this.buffers[key];
this.gl.deleteProgram(buffer.program);
}

this.program = null;
this.gl = null;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/GlslCanvas.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/GlslCanvas.min.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion lib/GlslCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ var GlslCanvas = function () {
this.uniforms = {};
this.vbo = {};
this.isValid = false;
this.animationFrameRequest = undefined;

this.BUFFER_COUNT = 0;
// this.TEXTURE_COUNT = 0;
Expand Down Expand Up @@ -1493,7 +1494,7 @@ var GlslCanvas = function () {
}

sandbox.render();
window.requestAnimationFrame(RenderLoop);
sandbox.animationFrameRequest = window.requestAnimationFrame(RenderLoop);
}

// Start
Expand All @@ -1505,6 +1506,9 @@ var GlslCanvas = function () {
createClass(GlslCanvas, [{
key: 'destroy',
value: function destroy() {
// Stop the animation
cancelAnimationFrame(this.animationFrameRequest);

this.animated = false;
this.isValid = false;
for (var tex in this.textures) {
Expand All @@ -1522,6 +1526,7 @@ var GlslCanvas = function () {
var buffer = this.buffers[key];
this.gl.deleteProgram(buffer.program);
}

this.program = null;
this.gl = null;
}
Expand Down
7 changes: 6 additions & 1 deletion src/GlslCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class GlslCanvas {
this.uniforms = {};
this.vbo = {};
this.isValid = false;
this.animationFrameRequest = undefined;

this.BUFFER_COUNT = 0;
// this.TEXTURE_COUNT = 0;
Expand Down Expand Up @@ -173,7 +174,7 @@ void main(){
}

sandbox.render();
window.requestAnimationFrame(RenderLoop);
sandbox.animationFrameRequest = window.requestAnimationFrame(RenderLoop);
}

// Start
Expand All @@ -183,6 +184,9 @@ void main(){
}

destroy() {
// Stop the animation
cancelAnimationFrame(this.animationFrameRequest);

this.animated = false;
this.isValid = false;
for (let tex in this.textures) {
Expand All @@ -200,6 +204,7 @@ void main(){
const buffer = this.buffers[key];
this.gl.deleteProgram(buffer.program);
}

this.program = null;
this.gl = null;
}
Expand Down