repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 5949978d3c3949b6b2d3aed611b63fad52453f5b:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 5949978d3c3949b6b2d3aed611b63fad52453f5b
Author: James Baicoianu 
Date:   Tue Nov 7 16:46:05 2017 -0800

    Move bounding sphere update into main update loop

diff --git a/scripts/janusparticle.js b/scripts/janusparticle.js
index b327552749aa2de812b81ecfff6b620c7b2cad05..
index ..69fd07a35d005f75da78cfb3822fece4825ea89a 100644
--- a/scripts/janusparticle.js
+++ b/scripts/janusparticle.js
@@ -36,7 +36,7 @@ elation.require(['janusweb.janusbase'], function() {
       this.started = false;
       this.pickable = false;
       this.collidable = false;
-
+      this.lastboundingsphereupdate = 0;
       this.updateParticles = elation.bind(this, this.updateParticles); // FIXME - hack, this should happen at the lower level of all components
     }
     this.createObject3D = function() {
@@ -152,9 +152,6 @@ elation.require(['janusweb.janusbase'], function() {
       this.lasttime = performance.now();

       this.updateBoundingSphere();
-      if (this.duration > 0) {
-        setInterval(elation.bind(this, this.updateBoundingSphere), this.duration * 1000);
-      }
     }
     this.resetParticles = function() {
       var geo = this.geometry;
@@ -212,6 +209,11 @@ elation.require(['janusweb.janusbase'], function() {

       this.geometry.attributes.position.needsUpdate = true;
       this.geometry.attributes.color.needsUpdate = true;
+
+      if (now - this.lastboundingsphereupdate > this.duration * 1000) {
+        this.updateBoundingSphere();
+        this.lastboundingsphereupdate = now;
+      }
       this.refresh();
     }
     this.updateBoundingSphere = function() {

-----END OF PAGE-----