Skip to content

Commit

Permalink
Allow compilation to be paused
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed May 24, 2016
1 parent b0cf5b9 commit de6baf4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/core/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ var SceneJS_Engine = function (json, options) {
*/
this._sceneBranchesDirty = false;

/**
* Flag to prevent engine from re-compiling the scene graph
*/
this._compilationPaused = false;

/**
* List of nodes scheduled for destruction by #destroyNode
* Destructions are done in a batch at the end of each render so as not to disrupt the render.
Expand Down Expand Up @@ -582,10 +587,28 @@ SceneJS_Engine.prototype._needCompile = function () {
|| this.sceneDirty); // Whole scene needs recompilation
};

/**
* Prevent engine from compiling the scene graph
*/
SceneJS_Engine.prototype.pauseCompilation = function () {
this._compilationPaused = true;
};

/**
* Resume compilation of scene graph
*/
SceneJS_Engine.prototype.resumeCompilation = function () {
this._compilationPaused = false;
};

/**
* Performs any pending scene compilations or display rebuilds
*/
SceneJS_Engine.prototype.compile = function () {
if (this._compilationPaused) {
return;
}

if (this._sceneBranchesDirty || this.sceneDirty) { // Need scene graph compilation
this._sceneBranchesDirty = false;
SceneJS_events.fireEvent(SceneJS_events.SCENE_COMPILING, { // Notify compilation support start
Expand Down
16 changes: 15 additions & 1 deletion src/core/scene/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,24 @@ SceneJS.Scene.prototype.renderFrame = function (params) {
return this._engine.renderFrame(params);
};

/**
* Prevent re-compilation of scene graph.
*/
SceneJS.Scene.prototype.pauseCompilation = function () {
return this._engine.pauseCompilation();
};

/**
* Resume re-compilation of scene graph.
*/
SceneJS.Scene.prototype.resumeCompilation = function () {
return this._engine.resumeCompilation();
};

/**
* Force compilation of the scene graph.
*/
SceneJS.Scene.prototype.compile = function (params) {
SceneJS.Scene.prototype.compile = function () {
return this._engine.compile();
};

Expand Down

0 comments on commit de6baf4

Please sign in to comment.