repo: janusweb
action: commit
revision: 
path_from: 
revision_from: b980f12a88cdb8f7bbbef4cc93b1a594d5cba2f8:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit b980f12a88cdb8f7bbbef4cc93b1a594d5cba2f8
Author: James Baicoianu 
Date:   Sat Jul 22 13:56:40 2017 -0700

    Remove old collider when setting new one

diff --git a/scripts/object.js b/scripts/object.js
index 155adf1ed501be47d1e343aa549a5274997e283a..
index ..58d0a74050d2bd5cda6d5623a7181569a091db78 100644
--- a/scripts/object.js
+++ b/scripts/object.js
@@ -79,6 +79,7 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
       this.updateCollider();
     }
     this.updateCollider = function() {
+      this.removeCollider();
       if (!this.collidable || !this.objects['dynamics']) return;
       var collision_id = this.collision_id || this.collider_id;
       var collision_scale = this.properties.collision_scale || this.properties.scale;
@@ -99,7 +100,7 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
           halfsize.z = .1;
           this.setCollider('box', {min: halfsize.clone().negate(), max: halfsize});
         } else if (collision_id == 'cylinder') {
-          this.setCollider('cylinder', {height: collision_scale.y, radius: Math.max(collision_scale.x, collision_scale.z) / 2, offset: new THREE.Vector3(0, 0.5 * collision_scale.y, 0)});
+          this.setCollider('cylinder', {height: 1, radius: .5, offset: new THREE.Vector3(0, 0.5, 0)});
         } else {
           var colliderasset = this.getAsset('model', collision_id);
           if (colliderasset) {
@@ -130,6 +131,14 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
         }
       }
     }
+    this.removeCollider = function() {
+      if (this.colliders) {
+        for (var i = 0; i < this.colliders.children.length; i++) {
+          var collider = this.colliders.children[i];
+          collider.parent.remove(collider);
+        }
+      }
+    }
     this.createObjectDOM = function() {
 /*
       if (this.websurface_id) {

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