Improved perf of previewer (remove useless clear)

This commit is contained in:
Thomas FORGIONE 2015-06-04 15:08:23 +02:00
parent 36eecfad97
commit 27752fa6e3
1 changed files with 13 additions and 4 deletions

View File

@ -8,6 +8,8 @@ var Previewer = function(renderer, scene) {
this.renderer = renderer;
this.fixed = false;
this.scene = scene;
this.drawn = false;
this.drawnBefore = false;
}
Previewer.prototype.render = function(prev, container_width, container_height) {
@ -60,10 +62,12 @@ Previewer.prototype.render = function(prev, container_width, container_height) {
this.renderer.setViewport(left, bottom, width, height);
this.renderer.render(this.scene, prev.camera);
if (!this.fixed) {
this.clearNeeded = true;
this.update(true);
} else {
this.update(false);
}
} else if (this.fixed) {
if (this.drawnBefore && !this.drawn) {
this.clearNeeded = true;
}
}
@ -78,3 +82,8 @@ Previewer.prototype.clear = function() {
Previewer.prototype.fixedRecommendation = function(bool) {
this.fixed = bool;
}
Previewer.prototype.update = function(arg) {
this.drawnBefore = this.drawn;
this.drawn = arg;
}