repo: janusweb action: commit revision: path_from: revision_from: 1219fd0893586c14dcefbe17ac9cf7c6bfcae041: path_to: revision_to:
commit 1219fd0893586c14dcefbe17ac9cf7c6bfcae041 Author: James BaicoianuDate: Thu Apr 14 05:34:48 2016 -0700 More abstraction for image aspect ratio calculation diff --git a/scripts/image.js b/scripts/image.js
--- a/scripts/image.js
+++ b/scripts/image.js
@@ -62,13 +62,8 @@ elation.require(['engine.things.generic'], function() {
}
}
this.createGeometry = function() {
- var aspect = 1,
+ var aspect = this.getAspect(),
thickness = .1;
- if (this.texture && this.texture.image) {
- aspect = this.texture.image.height / this.texture.image.width;
- }
- if (this.properties.sbs3d) aspect *= 2;
- if (this.properties.ou3d) aspect /= 2;
var box = new THREE.BoxGeometry(2, 2 * aspect, thickness);
box.applyMatrix(new THREE.Matrix4().makeTranslation(0, 0, thickness / 2));
return box;
@@ -96,6 +91,19 @@ elation.require(['engine.things.generic'], function() {
this.sidematerial = sidemat;
return facemat;
}
+ this.getAspect = function() {
+ var aspect = 1;
+ if (this.texture && this.texture.image) {
+ var size = this.getSize(this.texture.image);
+ aspect = size.height / size.width;
+ }
+ if (this.properties.sbs3d || this.asset.sbs3d) aspect *= 2;
+ if (this.properties.ou3d || this.asset.ou3d) aspect /= 2;
+ return aspect;
+ }
+ this.getSize = function(image) {
+ return {width: image.width, height: image.height};
+ }
this.adjustAspectRatio = function() {
var img = this.texture.image;
var geo = this.createGeometry();
-----END OF PAGE-----