-- 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: e913e6c1542a3a8728c1955a815735753c490c10:
path_to:
revision_to:

git.thebackupbox.net

janusweb

git://git.thebackupbox.net/janusweb

commit e913e6c1542a3a8728c1955a815735753c490c10
Author: James Baicoianu <james_github@baicoianu.com>
Date:   Sun Oct 31 02:00:49 2021 -0700

    Added object.applyPosition()

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

index 0f23546f6edf12c5902182b847cb58e983d68935..

index ..e4bc2dc2e9e9f0c0ac3bd9ca7776b3b9e2fe1274 100644

--- a/scripts/object.js
+++ b/scripts/object.js
@@ -1296,6 +1296,24 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
         this.morphtargetInfluences[this.morphtargets[name]] = value;
       }
     }
+    this.applyPosition = function(pos) {
+      if (!this.modelasset) this.assignTextures();
+
+      let mat4 = new THREE.Matrix4().makeTranslation(+pos.x, +pos.y, +pos.z);
+      if (this.modelasset && this.modelasset.loaded) {
+        // FIXME - should we handle the case where the object is already loaded and we want to modify its origin?
+        //         Currently we do nothing, so we don't double-apply
+      } else {
+        elation.events.add(this.modelasset, 'asset_load', ev => {
+          this.objects['3d'].traverse(n => {
+            if (n instanceof THREE.Mesh) {
+              n.geometry.applyMatrix4(mat4);
+            }
+          });
+        });
+      }
+
+    }
     this.getProxyObject = function(classdef) {
       if (!this._proxyobject) {
         this._proxyobject = elation.engine.things.janusobject.extendclass.getProxyObject.call(this, classdef);

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

-- Response ended

-- Page fetched on Sun Nov 10 19:49:57 2024