-- 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: 8db88f4443af98c4b82f4fd5b86ea3a15932f474:
path_to:
revision_to:

git.thebackupbox.net

janusweb

git://git.thebackupbox.net/janusweb

commit 8db88f4443af98c4b82f4fd5b86ea3a15932f474
Author: James Baicoianu <james_github@baicoianu.com>
Date:   Sun May 13 22:09:11 2018 -0700

    Added parts system for accessing individual model elements

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

index d46ce9c030138f41035711a78fe43069c85dbb37..

index ..84dbb0ea4492f866d7cc7d448e4df1c64211e93d 100644

--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -1,4 +1,4 @@
-elation.require(['engine.things.generic', 'utils.template'], function() {
+elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], function() {
   elation.template.add('janusweb.edit.object',
       '<Object id=^{id}^ js_id=^{js_id}^ alphatest=^{alphatest}^ locked=^false^ pos=^{pos.x} {pos.y} {pos.z}^ vel=^{vel.x} {vel.y} {vel.z}^ accel=^{accel.x} {accel.y} {accel.z}^ xdir=^{xdir}^ ydir=^{ydir}^ zdir=^{zdir}^ scale=^{scale.x} {scale.y} {scale.z}^ col=^{col}^ lighting=^{lighting}^ visible=^{visible}^ />');

@@ -10,6 +10,9 @@ elation.require(['engine.things.generic', 'utils.template'], function() {
       this.frameupdates = {};
       this.jschildren = [];
       this.assets = {};
+
+      this.jsparts = new elation.janusweb.parts(this);
+
       this.defineProperties({
         room:     { type: 'object' },
         janus:    { type: 'object' },
@@ -237,6 +240,7 @@ console.log('got collider', collider, collision_id);
         this._proxyobject = new elation.proxy(this, {
           parent:   ['accessor', 'parent.getProxyObject'],
           children: ['accessor', 'getChildProxies'],
+          parts:    ['property', 'jsparts'],
           js_id:    ['property', 'properties.js_id'],
           pos:      ['property', 'position'],
           vel:      ['property', 'velocity'],
diff --git a/scripts/parts.js b/scripts/parts.js
new file mode 100644
index 0000000000000000000000000000000000000000..04bfef7be536af11a4d3c9151f7cc8c339433976
--- /dev/null
+++ b/scripts/parts.js
@@ -0,0 +1,48 @@
+elation.require([], function() {
+
+  elation.extend('janusweb.parts', class {
+    constructor(object) {
+      this._object = object;
+      this._parts = {};
+      this._proxies = {};
+      console.log('new shit', object);
+      //this.updateParts();
+    }
+    definePart(name, part) {
+      console.log('had a part', name, part);
+      Object.defineProperty(this, name, {
+        get: () => this.getPart(name),
+        enumerable: true,
+        configurable: true
+      });
+    }
+    updateParts() {
+      this._object.extractEntities();
+      var obj = this._object._target || this._object;
+      var parts = obj.parts;
+      for (var k in parts) {
+        this.definePart(k, parts[k]);
+      }
+    }
+    getPart(name) {
+      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',
+          name: name,
+          contaner: elation.html.create(),
+          engine: this._object.engine,
+          properties: {
+            object: part
+          }
+        });
+        // TODO - set up object hierarchy here
+        this._proxies[name] = this._parts[name].getProxyObject();
+        this._proxies[name].start();
+      }
+      return this._proxies[name];
+    }
+  })
+});
+

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

-- Response ended

-- Page fetched on Sun Jun 2 15:06:39 2024