Skip to content

Commit

Permalink
Fix AzimuthAngleLimits Reset
Browse files Browse the repository at this point in the history
  • Loading branch information
pchen66 committed Apr 27, 2020
1 parent 4626f08 commit 04cecbc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/lib/controls/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ function OrbitControls ( object, domElement ) {

let state = STATE.NONE;

// eslint-disable-next-line no-unused-vars
let keyUp, keyBottom, keyLeft, keyRight;

// for reset

this.target0 = this.target.clone();
Expand Down
16 changes: 12 additions & 4 deletions src/panorama/PanoMomentPanorama.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ PanoMomentPanorama.prototype = Object.assign( Object.create( Panorama.prototype
* @param {THREE.Object[]} controls
*/
onPanolensControls: function( { controls } ) {

const [ { minPolarAngle, maxPolarAngle } ] = controls;

Object.assign( this.defaults, { minPolarAngle, maxPolarAngle } );

this.controls = controls;

Expand Down Expand Up @@ -260,18 +264,22 @@ PanoMomentPanorama.prototype = Object.assign( Object.create( Panorama.prototype
*/
resetAzimuthAngleLimits: function( reset = false ) {

const { controls: [ OrbitControls ],
momentData: { contains_parallax, min_vertical_fov } , defaults, camera } = this;
const {
controls: [ OrbitControls ],
momentData: { contains_parallax, min_vertical_fov },
defaults: { minPolarAngle, maxPolarAngle },
camera
} = this;

if ( !contains_parallax ) return;
if ( !contains_parallax && !reset ) return;

const delta = THREE.Math.degToRad( ( 0.95 * min_vertical_fov - camera.fov ) / 2 );
const angles = {
minPolarAngle: Math.PI / 2 - delta,
maxPolarAngle: Math.PI / 2 + delta
};

Object.assign( OrbitControls, reset ? defaults : angles );
Object.assign( OrbitControls, reset ? { minPolarAngle, maxPolarAngle } : angles );

},

Expand Down

0 comments on commit 04cecbc

Please sign in to comment.