lxy 2 yıl önce
ebeveyn
işleme
cf1a1e0b53

+ 31 - 12
SDK/LenzCameraNativeModuleForRN/LenzCameraNativeModuleForRN/Classes/inner/PCSBaseViewController/PCSBaseViewController.m

@@ -123,6 +123,10 @@
 @property (nonatomic) NSLock *stitchkLock;
 @property (nonatomic) LenVideoStitchResult stitchResult;
 
+
+@property (nonatomic) NSNumber *startPitchX;
+@property (nonatomic) NSNumber *startRollY;
+
 @end
 
 @implementation PCSBaseViewController
@@ -164,8 +168,8 @@
 
     self.resourceModel = [[LenzCachedResourceModel alloc]init];
     self.motionManager = [[CMMotionManager alloc]init];
-    self.motionManager.deviceMotionUpdateInterval = 1/5.0;
-
+    self.motionManager.deviceMotionUpdateInterval = 1/5;
+    
 //    self.resultDict = [NSMutableDictionary dictionary];
     
     if (!JK_IS_IPHONE_X) {
@@ -798,25 +802,40 @@
     
     if (self.motionManager.deviceMotionAvailable) {
         __weak typeof(self)wearSelf = self;
+        
         [self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion * _Nullable motion, NSError * _Nullable error) {
-            CGFloat x = motion.rotationRate.x;
-            CGFloat y = motion.rotationRate.y;
+            if (!self.startPitchX && !self.startRollY) {
+                self.startPitchX = @(motion.attitude.pitch * 100);
+                self.startRollY = @(motion.attitude.roll *100);
+            }
+                        
+            double x = self.startPitchX.doubleValue - motion.attitude.pitch * 100;
+            double y = self.startRollY.doubleValue - motion.attitude.roll * 100;
+
             LenVideoStitchDirction dir = (LenVideoStitchDirction)wearSelf.panoramOrientationGuideView.selectedItemIndex;
             if (dir == LenVideoStitchDirctionLeft || dir == LenVideoStitchDirctionRight) {
-                if (fabs(x) < 0.05) {
+                if (fabs(x) < 3) {
+                    NSLog(@"~~~~~~~~~~水平");
                     [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirCenter dir:dir];
-                } else if (x > 0) {
-                    [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirUp dir:dir];
                 } else {
-                    [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirDown dir:dir];
+                    if (x > 0) {
+                        NSLog(@"~~~~~~~~~~向下");
+                        [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirDown dir:dir];
+                    } else {
+                        NSLog(@"~~~~~~~~~~向上");
+                        [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirUp dir:dir];
+                    }
                 }
             } else if (dir == LenVideoStitchDirctionUp || dir == LenVideoStitchDirctionDown) {
-                if (fabs(y) < 0.05) {
+                
+                if (fabs(y) < 3) {
                     [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirCenter dir:dir];
-                } else if (y > 0) {
-                    [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirLeft dir:dir];
                 } else {
-                    [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirRight dir:dir];
+                    if (y > 0) {
+                        [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirLeft dir:dir];
+                    } else {
+                        [wearSelf.panoramaGuideView updateArrowWith:PanoramaArrowDirRight dir:dir];
+                    }
                 }
             }
             

+ 5 - 0
SDK/LenzCameraNativeModuleForRN/LenzCameraNativeModuleForRN/Classes/inner/UI/PanoramaGuideView/PanoramaGuideView.m

@@ -43,6 +43,7 @@ CGFloat const PanoramaGuideViewWOrH = 120;
 
 
 @property (nonatomic) UIImageView *showImageView;
+@property (nonatomic) PanoramaArrowDir lastArrowDir;
 
 
 @end
@@ -316,6 +317,10 @@ CGFloat const PanoramaGuideViewWOrH = 120;
 }
 
 - (void)updateArrowWith:(PanoramaArrowDir)arrowDir dir:(PanoramaOrientationViewDirectionEnum)dir {
+    if (self.lastArrowDir == arrowDir) {
+        return;
+    }
+    self.lastArrowDir = arrowDir;
     dispatch_async(dispatch_get_main_queue(), ^{
         if (!self.showImageView.image) {
             return;