repo: janusweb action: commit revision: path_from: revision_from: 6da6a66cd269fbda606865f68fe7317cec3aabe8: path_to: revision_to:
commit 6da6a66cd269fbda606865f68fe7317cec3aabe8 Author: James BaicoianuDate: Sun Dec 2 01:46:56 2018 -0800 Object part handling improvements diff --git a/scripts/parts.js b/scripts/parts.js
--- 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-----