From 3e0ad30c101b27634ce61cf69d930bc0d8219ab2 Mon Sep 17 00:00:00 2001 From: "Thomas B. Lee" Date: Thu, 16 Apr 2015 07:54:31 -0600 Subject: [PATCH 1/3] maximum tilt up/down angle Added an option to set up the maximum tilt up/down angle --- example1.js | 3 +++ photo-sphere-viewer.js | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/example1.js b/example1.js index 66be2840c..1bee1e99a 100644 --- a/example1.js +++ b/example1.js @@ -53,6 +53,9 @@ function upload() { // Display the navigation bar navbar: true, + // Set max tilt angle + tiltUpMax: 40, + // Resize the panorama size: { width: '100%', diff --git a/photo-sphere-viewer.js b/photo-sphere-viewer.js index 6850a7e50..48fe06010 100644 --- a/photo-sphere-viewer.js +++ b/photo-sphere-viewer.js @@ -91,6 +91,21 @@ var PhotoSphereViewer = function(args) { return Math.max(min, Math.min(max, x)); } + /** + * Set maximum up and down angle + * @param phi + * @returns phi + */ + + var setTiltAngle = function (phi){ + if (phi > TILT_UP_MAX) { + phi = TILT_UP_MAX; + } else if (phi < TILT_DOWN_MAX) { + phi = TILT_DOWN_MAX; + } + return phi; + }; + /** * Starts to load the panorama * @return (void) @@ -558,7 +573,7 @@ var PhotoSphereViewer = function(args) { theta -= Math.floor(theta / (2.0 * Math.PI)) * 2.0 * Math.PI; phi += (y - mouse_y) * PSV_LAT_OFFSET; phi = stayBetween(phi, -Math.PI / 2.0, Math.PI / 2.0) - + phi = setTiltAngle(phi); mouse_x = x; mouse_y = y; render(); @@ -814,6 +829,10 @@ var PhotoSphereViewer = function(args) { // Minimal and maximal fields of view in degrees var PSV_FOV_MIN = (args.min_fov !== undefined) ? stayBetween(parseFloat(args.min_fov), 1, 179) : 30; var PSV_FOV_MAX = (args.max_fov !== undefined) ? stayBetween(parseFloat(args.max_fov), 1, 179) : 90; + + // Maximum tilt up / down angle + var TILT_UP_MAX = (args.tiltUpMax !== undefined) ? (Math.PI / 180) * args.tiltUpMax : Math.PI/2.0; + var TILT_DOWN_MAX = (args.tiltDownMax !== undefined) ? -(Math.PI / 180) * args.tiltDownMax : -Math.PI/2.0; // Animation constants var PSV_FRAMES_PER_SECOND = 60; From 5bc9c45bbbf89c455b809046f001e3e8cda5af98 Mon Sep 17 00:00:00 2001 From: "Thomas B. Lee" Date: Thu, 16 Apr 2015 08:09:36 -0600 Subject: [PATCH 2/3] Changed parameter names Changed parameter names in the same format with the other parameters --- example1.js | 2 +- photo-sphere-viewer.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/example1.js b/example1.js index 1bee1e99a..51b278a30 100644 --- a/example1.js +++ b/example1.js @@ -54,7 +54,7 @@ function upload() { navbar: true, // Set max tilt angle - tiltUpMax: 40, + tilt_up_max: 40, // Resize the panorama size: { diff --git a/photo-sphere-viewer.js b/photo-sphere-viewer.js index 48fe06010..63c6a49e6 100644 --- a/photo-sphere-viewer.js +++ b/photo-sphere-viewer.js @@ -41,6 +41,8 @@ * - navbar_style (Object) (optional) ({}) Style of the navigation bar * - loading_img (string) (optional) (null) Loading image URL or path (absolute or relative) * - size (Object) (optional) (null) Final size of the panorama container (e.g. {width: 500, height: 300}) + * - tilt_up_max (integer) (optional) (90) The maximum tilt up angle between 0 and 90 + * - tilt_down_max (integer) (optional) (90) The maximum tilt down angle between 0 and 90 **/ var PhotoSphereViewer = function(args) { @@ -92,7 +94,7 @@ var PhotoSphereViewer = function(args) { } /** - * Set maximum up and down angle + * Set maximum tilt up and down angle * @param phi * @returns phi */ @@ -831,8 +833,8 @@ var PhotoSphereViewer = function(args) { var PSV_FOV_MAX = (args.max_fov !== undefined) ? stayBetween(parseFloat(args.max_fov), 1, 179) : 90; // Maximum tilt up / down angle - var TILT_UP_MAX = (args.tiltUpMax !== undefined) ? (Math.PI / 180) * args.tiltUpMax : Math.PI/2.0; - var TILT_DOWN_MAX = (args.tiltDownMax !== undefined) ? -(Math.PI / 180) * args.tiltDownMax : -Math.PI/2.0; + var TILT_UP_MAX = (args.tilt_up_max !== undefined) ? (Math.PI / 180) * args.tilt_up_max : Math.PI/2.0; + var TILT_DOWN_MAX = (args.tilt_down_max !== undefined) ? -(Math.PI / 180) * args.tilt_down_max : -Math.PI/2.0; // Animation constants var PSV_FRAMES_PER_SECOND = 60; From 87e57b1141b460d1cd51db8346f7350bbf250d89 Mon Sep 17 00:00:00 2001 From: "Thomas B. Lee" Date: Thu, 16 Apr 2015 08:18:54 -0600 Subject: [PATCH 3/3] change data type changed integer to number in comment --- photo-sphere-viewer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/photo-sphere-viewer.js b/photo-sphere-viewer.js index 63c6a49e6..012952e36 100644 --- a/photo-sphere-viewer.js +++ b/photo-sphere-viewer.js @@ -41,8 +41,8 @@ * - navbar_style (Object) (optional) ({}) Style of the navigation bar * - loading_img (string) (optional) (null) Loading image URL or path (absolute or relative) * - size (Object) (optional) (null) Final size of the panorama container (e.g. {width: 500, height: 300}) - * - tilt_up_max (integer) (optional) (90) The maximum tilt up angle between 0 and 90 - * - tilt_down_max (integer) (optional) (90) The maximum tilt down angle between 0 and 90 + * - tilt_up_max (number) (optional) (90) The maximum tilt up angle between 0 and 90 + * - tilt_down_max (number) (optional) (90) The maximum tilt down angle between 0 and 90 **/ var PhotoSphereViewer = function(args) {