repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 0b639af8b481a679f88f207779df8cae875922d6:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 0b639af8b481a679f88f207779df8cae875922d6
Author: James Baicoianu 
Date:   Wed Feb 24 16:02:02 2016 -0800

    Added collision_id for objects, attempted hack to fix transparency

diff --git a/scripts/object.js b/scripts/object.js
index 6aa5421c6adbd4c87879a9d51b1f172566b2daf9..
index ..7ef589e43a1c0267970a164b249226d6a5113a02 100644
--- a/scripts/object.js
+++ b/scripts/object.js
@@ -10,6 +10,7 @@ elation.require(['engine.things.generic'], function() {
         room: { type: 'object' },
         image_id: { type: 'string' },
         video_id: { type: 'string' },
+        collision_id: { type: 'string' },
         websurface_id: { type: 'string' },
         lighting: { type: 'boolean', default: true },
         col: { type: 'string' },
@@ -39,6 +40,16 @@ elation.require(['engine.things.generic'], function() {
         var vel = new THREE.Euler().setFromQuaternion(q);
         this.objects.dynamics.setAngularVelocity(vel);
       }
+
+      if (this.properties.collision_id) {
+        var collider = elation.engine.assets.find('model', this.properties.collision_id);
+        if (collider.userData.loaded) {
+          this.extractColliders(collider, true);
+        } else {
+          elation.events.add(collider, 'asset_load', elation.bind(this, function(ev) { this.extractColliders(collider, true); }) );
+        }
+        
+      }
     }
     this.createObjectDOM = function() {
       return;
@@ -113,7 +124,10 @@ elation.require(['engine.things.generic'], function() {
           materials.forEach(function(m) {
             if (texture) {
               m.map = texture; 
-              m.transparent = true;
+              // FIXME - hack for transparent PNGs
+              if (m.map && m.map.sourceFile && m.map.sourceFile.match(/[^0-9]\.(png|tga)$/)) {
+                m.transparent = true;
+              }
             }
             if (color && m.color) {
               m.color.copy(color);

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