repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 6da6a66cd269fbda606865f68fe7317cec3aabe8:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 6da6a66cd269fbda606865f68fe7317cec3aabe8
Author: James Baicoianu 
Date:   Sun Dec 2 01:46:56 2018 -0800

    Object part handling improvements

diff --git a/scripts/parts.js b/scripts/parts.js
index a9814d7b4edaa6a3aaf442d9c0c4cdbf1cf8dc7a..
index ..2242cd1fb1a2ce2fb10812228109ed2ff57eae1d 100644
--- a/scripts/parts.js
+++ b/scripts/parts.js
@@ -9,7 +9,7 @@ elation.require([], function() {
     }
     definePart(name, part) {
       Object.defineProperty(this, name, {
-        get: () => this.getPart(name),
+        get: () => this.getPartByName(name),
         enumerable: true,
         configurable: true
       });
@@ -22,17 +22,21 @@ elation.require([], function() {
         this.definePart(k, parts[k]);
       }
     }
-    getPart(name) {
+    getPartForObject(object) {
+      let name = object.name || object.uuid;
       if (!this._proxies[name]) {
-        var obj = this._object._target || this._object;
-        var part = obj.parts[name];
-        this._parts[name] = elation.engine.things.janusbase({
-          type: 'janusbase',
+        var rootobject = this._object._target || this._object;
+//console.log('replace the part', name, part.rotation, part.parent, part);
+        this._parts[name] = elation.engine.things.janusobject({
+          type: 'janusobject',
+          id: rootobject.id + '_parts_' + name,
           name: name,
           contaner: elation.html.create(),
           engine: this._object.engine,
           properties: {
-            object: part
+            object: object,
+            rotation: [object.rotation.x * THREE.Math.RAD2DEG, object.rotation.y * THREE.Math.RAD2DEG, object.rotation.z * THREE.Math.RAD2DEG], 
+            room: rootobject.room
           }
         });
         // TODO - set up object hierarchy here
@@ -41,6 +45,16 @@ elation.require([], function() {
       }
       return this._proxies[name];
     }
+    getPartByName(name) {
+      if (!this._proxies[name]) {
+        var obj = this._object._target || this._object;
+        var part = obj.parts[name];
+        if (part) {
+          return this.getPartForObject(part);
+        }
+      }
+      return this._proxies[name];
+    }
   })
 });

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