Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use correct starting angle for initial user pan check #62

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/NYT360CameraController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#import "NYT360EulerAngleCalculations.h"
#import "NYT360CameraPanGestureRecognizer.h"

static const CGPoint startingPosition = { 3.14, 0 };

static inline CGFloat distance(CGPoint a, CGPoint b) {
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
}
Expand Down Expand Up @@ -48,7 +50,7 @@ - (instancetype)initWithView:(SCNView *)view motionManager:(id<NYT360MotionManag

_pointOfView = view.pointOfView;
_view = view;
_currentPosition = CGPointMake(3.14, 0);
_currentPosition = startingPosition;
_allowedDeviceMotionPanningAxes = NYT360PanningAxisHorizontal | NYT360PanningAxisVertical;
_allowedPanGesturePanningAxes = NYT360PanningAxisHorizontal | NYT360PanningAxisVertical;

Expand Down Expand Up @@ -116,7 +118,7 @@ - (void)updateCameraAngleForCurrentDeviceMotion {
}

static const CGFloat minimalRotationDistanceToReport = 0.75;
if (distance(CGPointZero, self.currentPosition) > minimalRotationDistanceToReport) {
if (distance(startingPosition, self.currentPosition) > minimalRotationDistanceToReport) {
[self reportInitialCameraMovementIfNeededViaMethod:NYT360UserInteractionMethodGyroscope];
}
}
Expand Down