repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 342649e2bf568fba9ea01c0665771140defb7d2e:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 342649e2bf568fba9ea01c0665771140defb7d2e
Author: James Baicoianu 
Date:   Sat Jul 4 07:04:53 2020 -0700

    Adjust aspect ratio of portals to fit image

diff --git a/scripts/portal.js b/scripts/portal.js
index 1d1b52869a919ef1ce27b6b2b15b58089df7b44a..
index ..7a4dc7262c15183f3b3d865104aa492ebf7beb15 100644
--- a/scripts/portal.js
+++ b/scripts/portal.js
@@ -88,12 +88,14 @@ elation.require(['janusweb.janusbase'], function() {
               mat.transparent = true;
               mat.alphaTest = 0.1;
             }
+            this.adjustAspectRatio(asset.rawimage);
           } else {
             elation.events.add(thumb, 'asset_load', function() {
               if (mat && asset.hasalpha) {
                 mat.transparent = true;
                 mat.alphaTest = 0.1;
               }
+              this.adjustAspectRatio(asset.rawimage);
             });
           }
           elation.events.add(thumb, 'asset_update', elation.bind(this, function(ev) { mat.map = ev.data; }));
@@ -101,6 +103,10 @@ elation.require(['janusweb.janusbase'], function() {
       }
       return mat;
     }
+    this.adjustAspectRatio = function(image) {
+      let aspect = image.width / image.height;
+      this.mesh.scale.set(aspect, 1, 1);
+    }
     this.updateMaterial = function() {
       if (this.objects['3d'] && this.material) {
         //this.material = this.objects['3d'].material = this.createMaterial();
@@ -114,12 +120,14 @@ elation.require(['janusweb.janusbase'], function() {
                 this.material.transparent = true;
                 this.material.alphaTest = 0.1;
               }
+              this.adjustAspectRatio(asset.rawimage);
             } else {
               elation.events.add(thumb, 'asset_load', elation.bind(this, function() {
                 if (this.material && asset.hasalpha) {
                   this.material.transparent = true;
                   this.material.alphaTest = 0.1;
                 }
+                this.adjustAspectRatio(asset.rawimage);
               }));
             }
           }

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