repo: janusweb action: commit revision: path_from: revision_from: 342649e2bf568fba9ea01c0665771140defb7d2e: path_to: revision_to:
commit 342649e2bf568fba9ea01c0665771140defb7d2e Author: James BaicoianuDate: 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
--- 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-----