Search code examples
iosuipangesturerecognizergoogle-vr360-panorama

Using PanGesture with GoogleVR Panorama


I need to display 360 images on iOS devices. I chose GoogleVR to do this (https://developers.google.com/vr/) and I'm using the GVRPanoramaView. (https://developers.google.com/vr/ios/vr-view)

_panoView = [[GVRPanoramaView alloc] initWithFrame:self.view.bounds];  
[_panoView loadImage:[UIImage imageNamed:@"VRTest.jpg"]];
[self.view addSubview:_panoView];

It works well, the image is displayed and I'm able to see all around using the device gyroscope.

I'd like to be able to move across the image using pan gesture but I can't find a way to achieve this using the given SDK.

Is it even possible ? I did not find anything in the documentation saying it's not ... but didn't find any solution either ...


Solution

  • In the end I used the web version of the same framework ... that handle both gyroscope and pan gesture (but only around y axis) ... https://developers.google.com/vr/concepts/vrview-web

    I embedded the framework in my app to have it local (I want to be able to load offline image) https://github.com/google/vrview

    Then I used a simple webview :

    UIWebView *webview = [[UIWebView alloc] initWithFrame:self.view.bounds];
    
    // Path depends of your bundle
    NSString *indexPath = [[NSBundle mainBundle] pathForResource:@"vrview/index" ofType:@"html"];
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"VRTest" ofType:@"jpg"];
    
    // load the local framework with the local image 
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?image=%@&is_stereo=false", indexPath, imagePath]]]];
    
    // Disable scroll because of collision with pan gesture
    webview.scrollView.scrollEnabled = NO;
    
    [self.view addSubview:webview];