From 27752fa6e3bd76d5c8d8d4f9f58725b0031410e8 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Thu, 4 Jun 2015 15:08:23 +0200 Subject: [PATCH] Improved perf of previewer (remove useless clear) --- js/prototype/Previewer.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/js/prototype/Previewer.js b/js/prototype/Previewer.js index ad62e2a..39ad4e8 100644 --- a/js/prototype/Previewer.js +++ b/js/prototype/Previewer.js @@ -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; - } - } else if (this.fixed) { + this.update(true); + } else { + this.update(false); + } + + 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; +}