-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: janusweb
action: commit
revision:
path_from:
revision_from: 2975b2c86f626e0cc28dfa15d4a4ae089d296b56:
path_to:
revision_to:

git.thebackupbox.net

janusweb

git://git.thebackupbox.net/janusweb

commit 2975b2c86f626e0cc28dfa15d4a4ae089d296b56
Author: James Baicoianu <james_github@baicoianu.com>
Date:   Fri Nov 19 22:12:24 2021 -0800

    Optimize particle bounding sphere calculations

diff --git a/scripts/janusparticle.js b/scripts/janusparticle.js

index d803b53ef08b00b1b311dec1d16a5b1ebc5dcd58..

index ..54b1abd89c5fc1b842cfe4ab52a19a03cad818b4 100644

--- a/scripts/janusparticle.js
+++ b/scripts/janusparticle.js
@@ -67,6 +67,7 @@ elation.require(['janusweb.janusbase'], function() {
       this.collidable = false;
       this.boundingRadiusSq = 0;
       this.boundingSphereWorld = new THREE.Sphere();
+      this.furthestPoint = new THREE.Vector3();
       this.lastrefresh = 0;
       this.updateParticles = elation.bind(this, this.updateParticles); // FIXME - hack, this should happen at the lower level of all components
     }
@@ -324,11 +325,19 @@ elation.require(['janusweb.janusbase'], function() {
       // We also rate limit here, so if nothing else in the scene is changing, we
       // render at a lower fps
       this.localToWorld(this.boundingSphereWorld.center.set(0,0,0));
-      if (!this.objects['3d'].geometry.boundingSphere) {
-        this.objects['3d'].geometry.computeBoundingSphere();
+      let geo = this.objects['3d'].geometry;
+      if (!geo.boundingSphere) {
+        geo.computeBoundingSphere();
+      } else {
+        let currentBoundingRadius = geo.boundingSphere.radius
+        if (this.boundingRadiusSq > currentBoundingRadius * currentBoundingRadius) {
+           geo.boundingSphere.radius = Math.sqrt(this.boundingRadiusSq) + .1;
+        }
       }
-      this.boundingSphereWorld.radius = this.objects['3d'].geometry.boundingSphere.radius;
+
+      this.boundingSphereWorld.radius = geo.boundingSphere.radius;
       if (player.viewfrustum.intersectsSphere(this.boundingSphereWorld) && now - this.lastrefresh > (1000 / this.refreshrate)) {
+
         this.refresh();
         this.lastrefresh = now;
       }
@@ -341,11 +350,14 @@ elation.require(['janusweb.janusbase'], function() {
         var lengthSq = vec.lengthSq();
         if (lengthSq > this.boundingRadiusSq) {
           this.boundingRadiusSq = lengthSq;
+          this.furthestPoint.copy(vec);
+/*
           var geo = this.objects['3d'].geometry;
           if (!geo.boundingSphere) {
             geo.boundingSphere = new THREE.Sphere();
           }
           geo.boundingSphere.radius = Math.sqrt(lengthSq);
+*/
         }
       }
     }

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

-- Response ended

-- Page fetched on Sun Jun 2 15:53:32 2024