From b6b3b0ea1968031955fc5c373c8cfd866729c86a Mon Sep 17 00:00:00 2001 From: Damien SOREL Date: Thu, 27 Jul 2017 14:12:52 +0200 Subject: [PATCH 1/7] Use Node version of SASS Fix #143 --- .sass-lint.yml | 13 +++++++++++++ .scss-lint.yml | 19 ------------------- .travis.yml | 2 -- Gruntfile.js | 13 ++++++------- README.md | 2 -- package.json | 6 +++--- src/scss/_vars.scss | 11 ++++++----- src/scss/buttons/markers.scss | 6 ++++-- src/scss/buttons/zoom.scss | 6 ++++-- src/scss/loader.scss | 6 ++++-- src/scss/navbar.scss | 6 +++--- src/scss/panel.scss | 9 ++++++--- 12 files changed, 49 insertions(+), 50 deletions(-) create mode 100644 .sass-lint.yml delete mode 100644 .scss-lint.yml diff --git a/.sass-lint.yml b/.sass-lint.yml new file mode 100644 index 000000000..d5b5d03f6 --- /dev/null +++ b/.sass-lint.yml @@ -0,0 +1,13 @@ +rules: + property-sort-order: [0] + force-pseudo-nesting: [0] + force-element-nesting: [0] + force-attribute-nesting: [0] + no-important: [0] + no-qualifying-elements: [0] + no-transition-all: [0] + shorthand-values: [1, {allowed-shorthands: [1, 2, 4]}] + +files: + ignore: + - 'src/scss/_mixins.scss' diff --git a/.scss-lint.yml b/.scss-lint.yml deleted file mode 100644 index 545631c23..000000000 --- a/.scss-lint.yml +++ /dev/null @@ -1,19 +0,0 @@ -linters: - PropertySortOrder: - enabled: false - - SingleLinePerSelector: - enabled: false - - SelectorDepth: - max_depth: 4 - - NestingDepth: - max_depth: 4 - - HexLength: - enabled: false - - VendorPrefix: - exclude: - - src/scss/_mixins.scss diff --git a/.travis.yml b/.travis.yml index cb9c05917..4fff14554 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,6 @@ language: node_js node_js: - "5" before_install: - - gem install sass - - gem install scss_lint -v 0.49.0 - npm install -g grunt-cli - npm install -g bower before_script: diff --git a/Gruntfile.js b/Gruntfile.js index 9a7dd8019..6ae1520b3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,7 +1,7 @@ module.exports = function(grunt) { require('time-grunt')(grunt); require('jit-grunt')(grunt, { - scsslint: 'grunt-scss-lint', + sasslint: 'grunt-sass-lint', usebanner: 'grunt-banner' }); @@ -98,8 +98,8 @@ module.exports = function(grunt) { */ sass: { options: { - sourcemap: 'none', - style: 'expanded' + sourceMap: false, + outputStyle: 'expanded' }, lib: { src: 'src/scss/photo-sphere-viewer.scss', @@ -150,10 +150,9 @@ module.exports = function(grunt) { /** * SCSSLint test on src files */ - scsslint: { + sasslint: { options: { - colorizeOutput: true, - config: '.scss-lint.yml' + configFile: '.sass-lint.yml' }, lib: { src: ['src/scss/**/*.scss'] @@ -297,7 +296,7 @@ module.exports = function(grunt) { grunt.registerTask('test', [ 'jshint', 'jscs', - 'scsslint', + 'sasslint', 'mochaTest' ]); diff --git a/README.md b/README.md index 899532108..bbfdc346f 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,8 @@ Photo Sphere Viewer is available on [jsDelivr](https://cdn.jsdelivr.net/npm/phot #### Prerequisites * NodeJS + NPM: `apt-get install nodejs-legacy npm` - * Ruby Dev: `apt-get install ruby-dev` * Grunt CLI: `npm install -g grunt-cli` * Bower: `npm install -g bower` - * SASS: `gem install sass` #### Run diff --git a/package.json b/package.json index fe061d25a..de765b997 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dot": ">=1.0.3" }, "devDependencies": { - "foodoc": "git://github.com/mistic100/foodoc.git#custom", + "foodoc": "^0.0.8", "grunt": "^1.0.0", "grunt-banner": "^0.6.0", "grunt-contrib-clean": "^1.0.0", @@ -31,14 +31,14 @@ "grunt-contrib-copy": "^1.0.0", "grunt-contrib-cssmin": "^2.0.0", "grunt-contrib-jshint": "^1.0.0", - "grunt-contrib-sass": "^1.0.0", "grunt-contrib-uglify": "^3.0.0", "grunt-contrib-watch": "^1.0.0", "grunt-jscs": "^3.0.1", "grunt-jsdoc": "^2.1.0", "grunt-mocha-test": "^0.13.2", "grunt-open": "^0.2.3", - "grunt-scss-lint": "^0.5.0", + "grunt-sass": "^2.0.0", + "grunt-sass-lint": "^0.2.2", "grunt-wrap": "^0.3.0", "jit-grunt": "^0.10.0", "mocha": "^3.2.0", diff --git a/src/scss/_vars.scss b/src/scss/_vars.scss index 302c059a8..0537b37a0 100644 --- a/src/scss/_vars.scss +++ b/src/scss/_vars.scss @@ -1,5 +1,6 @@ // scss-lint:disable ColorVariable -$psv-main-background: radial-gradient(#ffffff, #fdfdfd 16%, #fbfbfb 33%, #f8f8f8 49%, #efefef 66%, #dfdfdf 82%, #bfbfbf 100%) !default; +$psv-main-background-stops: #fff 0%, #fdfdfd 16%, #fbfbfb 33%, #f8f8f8 49%, #efefef 66%, #dfdfdf 82%, #bfbfbf 100%; +$psv-main-background: radial-gradient($psv-main-background-stops) !default; $psv-loader-color: rgba(61, 61, 61, .7) !default; $psv-loader-width: 150px !default; @@ -38,7 +39,7 @@ $psv-tooltip-max-width: 200px !default; $psv-tooltip-text-color: rgb(255, 255, 255) !default; $psv-tooltip-font: 14px sans-serif !default; -$psv-tooltip-text-shadow: 0 1px #000000 !default; +$psv-tooltip-text-shadow: 0 1px #000 !default; $psv-tooltip-shadow-color: rgba(90, 90, 90, .7) !default; // the shadow is always at the opposite side of the arrow @@ -53,12 +54,12 @@ $psv-panel-padding: 1em !default; // must be odd $psv-panel-resizer-width: 9px !default; $psv-panel-resizer-background: rgba(0, 0, 0, .9) !default; -$psv-panel-resizer-grip-color: #ffffff !default; +$psv-panel-resizer-grip-color: #fff !default; // must be odd $psv-panel-resizer-grip-height: 29px !default; $psv-panel-close-button-width: 24px !default; $psv-panel-close-button-background: $psv-panel-resizer-background !default; -$psv-panel-close-button-color: #ffffff !default; +$psv-panel-close-button-color: #fff !default; $psv-panel-font: 16px sans-serif !default; @@ -69,7 +70,7 @@ $psv-markers-list-hover-translation: 10px !default; $psv-markers-list-odd-background: rgba(255, 255, 255, .1) !default; $psv-markers-list-even-background: transparent !default; -$psv-markers-list-title-shadow: 2px 1px #000000 !default; +$psv-markers-list-title-shadow: 2px 1px #000 !default; $psv-markers-list-title-font: 24px sans-serif !default; $psv-canvas-zindex: 0 !default; diff --git a/src/scss/buttons/markers.scss b/src/scss/buttons/markers.scss index 72eddc1b0..74e474b50 100644 --- a/src/scss/buttons/markers.scss +++ b/src/scss/buttons/markers.scss @@ -30,11 +30,13 @@ margin-left: -$psv-markers-list-hover-translation; } - &:nth-child(odd), &:nth-child(odd)::before { + &:nth-child(odd), + &:nth-child(odd)::before { background: $psv-markers-list-odd-background; } - &:nth-child(even), &:nth-child(even)::before { + &:nth-child(even), + &:nth-child(even)::before { background: $psv-markers-list-even-background; } diff --git a/src/scss/buttons/zoom.scss b/src/scss/buttons/zoom.scss index 45b8032d0..1562afcec 100644 --- a/src/scss/buttons/zoom.scss +++ b/src/scss/buttons/zoom.scss @@ -2,7 +2,8 @@ cursor: default; width: #{$psv-zoom-buttons-width * 3 + $psv-zoom-range-width}; - &-minus, &-plus { + &-minus, + &-plus { float: left; position: relative; cursor: pointer; @@ -58,7 +59,8 @@ display: none; } - &-minus, &-plus { + &-minus, + &-plus { width: $psv-buttons-height; height: $psv-buttons-height; padding: $psv-buttons-padding; diff --git a/src/scss/loader.scss b/src/scss/loader.scss index 5453d365f..fd5aa4920 100644 --- a/src/scss/loader.scss +++ b/src/scss/loader.scss @@ -1,5 +1,5 @@ .psv-loader-container { - @include flexbox(); + @include flexbox; align-items: center; justify-content: center; position: absolute; @@ -26,7 +26,9 @@ vertical-align: middle; } - &, &-image, &-text { + &, + &-image, + &-text { display: inline-block; vertical-align: middle; } diff --git a/src/scss/navbar.scss b/src/scss/navbar.scss index 4b03f7193..2482cf699 100644 --- a/src/scss/navbar.scss +++ b/src/scss/navbar.scss @@ -1,5 +1,5 @@ .psv-navbar { - @include flexbox(); + @include flexbox; position: absolute; z-index: $psv-navbar-zindex; bottom: -$psv-navbar-height; @@ -13,8 +13,8 @@ bottom: 0; } - // scss-lint:disable UnnecessaryParentReference - &, & * { + &, + & * { box-sizing: content-box; } } diff --git a/src/scss/panel.scss b/src/scss/panel.scss index f51a5e922..e68da815e 100644 --- a/src/scss/panel.scss +++ b/src/scss/panel.scss @@ -29,7 +29,8 @@ $psv-panel-resizer-grip-width: $psv-panel-resizer-width - 4px; height: $psv-panel-close-button-width; background: $psv-panel-close-button-background; - &::before, &::after { + &::before, + &::after { content: ''; position: absolute; top: 50%; @@ -50,7 +51,8 @@ $psv-panel-resizer-grip-width: $psv-panel-resizer-width - 4px; } &:hover { - &::before, &::after { + &::before, + &::after { left: 0; width: $psv-panel-close-button-width - 1px; } @@ -113,7 +115,8 @@ $psv-panel-resizer-grip-width: $psv-panel-resizer-width - 4px; opacity: 1; transition-duration: .2s; - .psv-panel-close-button, .psv-panel-resizer { + .psv-panel-close-button, + .psv-panel-resizer { display: block; } } From 798912cf3f31a5b87f78efadd65c8016d29ac618 Mon Sep 17 00:00:00 2001 From: Samuel Gaus Date: Thu, 3 Aug 2017 12:44:13 +0100 Subject: [PATCH 2/7] Make AMD setup compatible with case sensitive filesystems (#140) --- src/js/.wrapper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/.wrapper.js b/src/js/.wrapper.js index c52733098..2e2af7571 100644 --- a/src/js/.wrapper.js +++ b/src/js/.wrapper.js @@ -1,9 +1,9 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { - define(['three', 'D.js', 'uevent', 'doT'], factory); + define(['three', 'd.js', 'uevent', 'dot/doT'], factory); } else if (typeof module === 'object' && module.exports) { - module.exports = factory(require('three'), require('d.js'), require('uevent'), require('dot')); + module.exports = factory(require('three'), require('d.js'), require('uevent'), require('dot/doT')); } else { root.PhotoSphereViewer = factory(root.THREE, root.D, root.uEvent, root.doT); From e59e8aad1f39526df7907eea2b88e225b555d96f Mon Sep 17 00:00:00 2001 From: Damien SOREL Date: Thu, 3 Aug 2017 14:03:28 +0200 Subject: [PATCH 3/7] Close #146 Add "resize" method --- Gruntfile.js | 2 +- src/js/PhotoSphereViewer.js | 7 +++++++ src/js/PhotoSphereViewer.public.js | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6ae1520b3..76397d2c2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -61,7 +61,7 @@ module.exports = function(grunt) { wrap: { dist: { src: 'dist/photo-sphere-viewer.js', - dest: '', + dest: 'dist/photo-sphere-viewer.js', options: { separator: '', wrapper: function() { diff --git a/src/js/PhotoSphereViewer.js b/src/js/PhotoSphereViewer.js index e92056858..77a0defc6 100644 --- a/src/js/PhotoSphereViewer.js +++ b/src/js/PhotoSphereViewer.js @@ -12,6 +12,13 @@ * @property {int} height */ +/** + * @typedef {Object} PhotoSphereViewer.CssSize + * @summary Object defining a size in CSS (px, % or auto) + * @property {string} [width] + * @property {string} [height] + */ + /** * @typedef {Object} PhotoSphereViewer.Position * @summary Object defining a spherical position diff --git a/src/js/PhotoSphereViewer.public.js b/src/js/PhotoSphereViewer.public.js index d78e0a20a..dfb502e73 100644 --- a/src/js/PhotoSphereViewer.public.js +++ b/src/js/PhotoSphereViewer.public.js @@ -517,6 +517,21 @@ PhotoSphereViewer.prototype.zoomOut = function() { } }; +/** + * @summary Resizes the viewer + * @param {PhotoSphereViewer.CssSize} size + */ +PhotoSphereViewer.prototype.resize = function(size) { + if (size.width) { + this.container.style.width = size.width; + } + if (size.height) { + this.container.style.height = size.height; + } + + this._onResize(); +}; + /** * @summary Enters or exits the fullscreen mode */ From bb72816ce7c98e478d3e29b69b9e0bfc8507c90b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 3 Oct 2017 08:50:45 +0200 Subject: [PATCH 4/7] chore(package): update mocha to version 4.0.0 (#156) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de765b997..db78d0936 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "grunt-sass-lint": "^0.2.2", "grunt-wrap": "^0.3.0", "jit-grunt": "^0.10.0", - "mocha": "^3.2.0", + "mocha": "^4.0.0", "simple-cli": "^4.0.0", "time-grunt": "^1.3.0" }, From 0e4f45db5bc0046d0642e066be19a0c8bd16453b Mon Sep 17 00:00:00 2001 From: Damien SOREL Date: Mon, 23 Oct 2017 13:25:27 +0200 Subject: [PATCH 5/7] Fix #154 warning button "markers" not found --- src/js/components/PSVHUD.js | 2 +- src/js/components/PSVNavBar.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/components/PSVHUD.js b/src/js/components/PSVHUD.js index cbd4e055b..f7775412b 100644 --- a/src/js/components/PSVHUD.js +++ b/src/js/components/PSVHUD.js @@ -41,7 +41,7 @@ function PSVHUD(psv) { this.prop = { panelOpened: false, panelOpening: false, - markersButton: this.psv.navbar.getNavbarButton('markers') + markersButton: this.psv.navbar.getNavbarButton('markers', true) }; this.create(); diff --git a/src/js/components/PSVNavBar.js b/src/js/components/PSVNavBar.js index 9fc093c2d..fcc176605 100644 --- a/src/js/components/PSVNavBar.js +++ b/src/js/components/PSVNavBar.js @@ -133,9 +133,10 @@ PSVNavBar.prototype.destroy = function() { /** * @summary Returns a button by its identifier * @param {string} id + * @param {boolean} [silent=false] * @returns {module:components/buttons.PSVNavBarButton} */ -PSVNavBar.prototype.getNavbarButton = function(id) { +PSVNavBar.prototype.getNavbarButton = function(id, silent) { var button = null; this.items.some(function(item) { @@ -145,7 +146,7 @@ PSVNavBar.prototype.getNavbarButton = function(id) { } }); - if (!button) { + if (!button && !silent) { console.warn('PhotoSphereViewer: button "' + id + '" not found in the navbar.'); } From c29befc111d6c4222484cc7f14629d5dabcb70f1 Mon Sep 17 00:00:00 2001 From: Lukas Drgon Date: Mon, 23 Oct 2017 18:25:20 +0200 Subject: [PATCH 6/7] Add jsDelivr hits badge (#157) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bbfdc346f..b3f60ed09 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Bower version](https://img.shields.io/bower/v/Photo-Sphere-Viewer.svg?style=flat-square)](http://photo-sphere-viewer.js.org) [![NPM version](https://img.shields.io/npm/v/photo-sphere-viewer.svg?style=flat-square)](https://www.npmjs.com/package/photo-sphere-viewer) +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/photo-sphere-viewer/badge)](https://www.jsdelivr.com/package/npm/photo-sphere-viewer) [![Build Status](https://img.shields.io/travis/mistic100/Photo-Sphere-Viewer/master.svg?style=flat-square)](https://travis-ci.org/mistic100/Photo-Sphere-Viewer) [![Dependencies Status](https://david-dm.org/mistic100/Photo-Sphere-Viewer/status.svg?style=flat-square)](https://david-dm.org/mistic100/Photo-Sphere-Viewer) From f76c869282f57d8d52b6e85a50b732de9f4cc8e8 Mon Sep 17 00:00:00 2001 From: Damien SOREL Date: Wed, 6 Dec 2017 13:55:03 +0100 Subject: [PATCH 7/7] Fix #150 Add `panorama_roll` option --- src/js/PSVMarker.js | 2 +- src/js/PSVUtils.js | 25 ++++++++++--------------- src/js/PhotoSphereViewer.core.js | 1 + src/js/PhotoSphereViewer.defaults.js | 1 + src/js/PhotoSphereViewer.js | 12 ++++++------ src/js/PhotoSphereViewer.utils.js | 6 +++--- tests/utils/index.js | 8 ++++---- 7 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/js/PSVMarker.js b/src/js/PSVMarker.js index c6ea42f32..f968b61c5 100644 --- a/src/js/PSVMarker.js +++ b/src/js/PSVMarker.js @@ -413,7 +413,7 @@ PSVMarker.prototype._updatePolygon = function() { this.polygon_rad = this.polygon_rad.map(function(coord) { return [ PSVUtils.parseAngle(coord[0]), - PSVUtils.bound(PSVUtils.parseAngle(coord[1], -Math.PI), -PSVUtils.HalfPI, PSVUtils.HalfPI) + PSVUtils.parseAngle(coord[1], true) ]; }); } diff --git a/src/js/PSVUtils.js b/src/js/PSVUtils.js index d3282d3b9..77e02252f 100644 --- a/src/js/PSVUtils.js +++ b/src/js/PSVUtils.js @@ -441,12 +441,12 @@ PSVUtils.parseSpeed = function(speed) { /** * @summary Parses an angle value in radians or degrees and returns a normalized value in radians * @param {string|number} angle - eg: 3.14, 3.14rad, 180deg - * @param {float|boolean} [reference=0] - base value for normalization, false to disable + * @param {boolean} [zeroCenter=false] - normalize between -Pi/2 - Pi/2 instead of 0 - 2*Pi * @returns {float} * @throws {PSVError} when the angle cannot be parsed */ -PSVUtils.parseAngle = function(angle, reference) { - if (typeof angle == 'string') { +PSVUtils.parseAngle = function(angle, zeroCenter) { + if (typeof angle === 'string') { var match = angle.toLowerCase().trim().match(/^(-?[0-9]+(?:\.[0-9]*)?)(.*)$/); if (!match) { @@ -470,23 +470,18 @@ PSVUtils.parseAngle = function(angle, reference) { throw new PSVError('unknown angle unit "' + unit + '"'); } } - } - - if (reference !== false) { - if (reference === undefined) { - reference = 0; + else { + angle = value; } + } - angle = (angle - reference) % PSVUtils.TwoPI; - - if (angle < 0) { - angle = PSVUtils.TwoPI + angle; - } + angle = (zeroCenter ? angle + Math.PI : angle) % PSVUtils.TwoPI; - angle += reference; + if (angle < 0) { + angle = PSVUtils.TwoPI + angle; } - return angle; + return zeroCenter ? PSVUtils.bound(angle - Math.PI, -PSVUtils.HalfPI, PSVUtils.HalfPI) : angle; }; /** diff --git a/src/js/PhotoSphereViewer.core.js b/src/js/PhotoSphereViewer.core.js index 8dffbfe04..5d8d69c1b 100644 --- a/src/js/PhotoSphereViewer.core.js +++ b/src/js/PhotoSphereViewer.core.js @@ -478,6 +478,7 @@ PhotoSphereViewer.prototype._createSphere = function() { this.mesh = new THREE.Mesh(geometry, material); this.mesh.scale.x = -1; + this.mesh.rotation.z = this.config.panorama_roll; this.scene.add(this.mesh); }; diff --git a/src/js/PhotoSphereViewer.defaults.js b/src/js/PhotoSphereViewer.defaults.js index b85fb52ca..10aac51db 100644 --- a/src/js/PhotoSphereViewer.defaults.js +++ b/src/js/PhotoSphereViewer.defaults.js @@ -122,6 +122,7 @@ PhotoSphereViewer.DEFAULTS = { default_fov: null, default_long: 0, default_lat: 0, + panorama_roll: 0, longitude_range: null, latitude_range: null, move_speed: 1, diff --git a/src/js/PhotoSphereViewer.js b/src/js/PhotoSphereViewer.js index 77a0defc6..08001965b 100644 --- a/src/js/PhotoSphereViewer.js +++ b/src/js/PhotoSphereViewer.js @@ -167,8 +167,10 @@ function PhotoSphereViewer(options) { this.config.default_long = PSVUtils.parseAngle(this.config.default_long); // parse default_lat, is between -PI/2 and PI/2 - this.config.default_lat = PSVUtils.parseAngle(this.config.default_lat, -Math.PI); - this.config.default_lat = PSVUtils.bound(this.config.default_lat, -PSVUtils.HalfPI, PSVUtils.HalfPI); + this.config.default_lat = PSVUtils.parseAngle(this.config.default_lat, true); + + // parse panorama_roll, is between -PI/2 and PI/2 + this.config.panorama_roll = PSVUtils.parseAngle(this.config.panorama_roll, true); // default anim_lat is default_lat if (this.config.anim_lat === null) { @@ -176,8 +178,7 @@ function PhotoSphereViewer(options) { } // parse anim_lat, is between -PI/2 and PI/2 else { - this.config.anim_lat = PSVUtils.parseAngle(this.config.anim_lat, -Math.PI); - this.config.anim_lat = PSVUtils.bound(this.config.anim_lat, -PSVUtils.HalfPI, PSVUtils.HalfPI); + this.config.anim_lat = PSVUtils.parseAngle(this.config.anim_lat, true); } // parse longitude_range, between 0 and 2*PI @@ -190,8 +191,7 @@ function PhotoSphereViewer(options) { // parse latitude_range, between -PI/2 and PI/2 if (this.config.latitude_range) { this.config.latitude_range = this.config.latitude_range.map(function(angle) { - angle = PSVUtils.parseAngle(angle, -Math.PI); - return PSVUtils.bound(angle, -PSVUtils.HalfPI, PSVUtils.HalfPI); + return PSVUtils.parseAngle(angle, true); }); } diff --git a/src/js/PhotoSphereViewer.utils.js b/src/js/PhotoSphereViewer.utils.js index 8c36052c9..c3d6c9325 100644 --- a/src/js/PhotoSphereViewer.utils.js +++ b/src/js/PhotoSphereViewer.utils.js @@ -167,7 +167,7 @@ PhotoSphereViewer.prototype.cleanPosition = function(position) { } position.longitude = PSVUtils.parseAngle(position.longitude); - position.latitude = PSVUtils.bound(PSVUtils.parseAngle(position.latitude, -Math.PI), -PSVUtils.HalfPI, PSVUtils.HalfPI); + position.latitude = PSVUtils.parseAngle(position.latitude, true); }; /** @@ -214,8 +214,8 @@ PhotoSphereViewer.prototype.applyRanges = function(position) { range = PSVUtils.clone(this.config.latitude_range); offset = THREE.Math.degToRad(this.prop.vFov) / 2; - range[0] = PSVUtils.parseAngle(Math.min(range[0] + offset, range[1]), -Math.PI); - range[1] = PSVUtils.parseAngle(Math.max(range[1] - offset, range[0]), -Math.PI); + range[0] = PSVUtils.parseAngle(Math.min(range[0] + offset, range[1]), true); + range[1] = PSVUtils.parseAngle(Math.max(range[1] - offset, range[0]), true); if (position.latitude < range[0]) { position.latitude = range[0]; diff --git a/tests/utils/index.js b/tests/utils/index.js index 81bc5c30d..4ead1eb88 100644 --- a/tests/utils/index.js +++ b/tests/utils/index.js @@ -52,14 +52,14 @@ describe('PSVUtils::parseAngle', function() { } }); - it('should normalize angles between -Pi and Pi', function() { + it('should normalize angles between -Pi/2 and Pi/2', function() { var values = { - '270deg': -Math.PI / 2, - '-4': 2 * Math.PI - 4 + '45deg': Math.PI / 4, + '-4': Math.PI / 2 }; for (var pos in values) { - assert.equal(PSVUtils.parseAngle(pos, -Math.PI).toFixed(16), values[pos].toFixed(16), pos); + assert.equal(PSVUtils.parseAngle(pos, true).toFixed(16), values[pos].toFixed(16), pos); } });