Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

Event 'getposition' not triggering? #300

Open
clarklyyc opened this issue Feb 1, 2018 · 4 comments
Open

Event 'getposition' not triggering? #300

clarklyyc opened this issue Feb 1, 2018 · 4 comments

Comments

@clarklyyc
Copy link

clarklyyc commented Feb 1, 2018

When does the 'getposition' event fire?

The code snippet below doesn't seem to trigger. It was copied and slightly modified from the hotspot example (https://googlevr.github.io/vrview/examples/hotspots/index.html).

this.VRView.on('getposition', (e) => {
  console.log(`getposition triggered - ${e}`)
})

I am currently self-hosting using the minimized files from https://github.com/googlevr/vrview#downloading-files

Thanks

@MarkMcCorrie
Copy link

I'm getting the same problem. When I call VRView.getPosition(), it isn't triggering that callback.

It's working on one of their example pages:
https://googlevr.github.io/vrview/examples/hotspots/index.html

I have hotspots working, I just need the getPosition to trigure to set the hotspots without messing around.

@clarklyyc
Copy link
Author

Hey Mark,

I managed to figure this out, you need to call .getPosition() in a click event handler, as well as a 'getposition' event listener. See code:

vrview.on('click', (e) => {
  vrview.getPosition() // call in click event
}

vrview.on('getposition', (e) => {
  console.log(`Yaw: ${e.Yaw}. Pitch: ${e.Pitch}.`) 
}

Hope this helps!

@MarkMcCorrie
Copy link

MarkMcCorrie commented Apr 3, 2018

My code already does that and it's still not working! It doesn't even run through my function when I all getPosition().

I've got it hosted here:
https://www.madesnappy.co.uk/example_360?id=1

gallery.view = new VRView.Player('#' + options.view, {
    image: 'Pictures/blank.png',
    preview: 'Pictures/blank.png',
    width: gallery.width + "px",
    height: gallery.height + "px",
    is_autopan_off: true
  });
  gallery.view.on("click", function(event) {
    gallery.view.getPosition();
    if (event.id) {
      gallery.load_scene(gallery.picture_index(event.id));
    }
  });
  gallery.view.on('getposition', function(event) {
    console.log(event.Yaw);
    console.log(event.Pitch);
  });
  gallery.view.on('ready', function(event) {
    gallery.load_scene(0);
  });

@MarkMcCorrie
Copy link

I've moved to http:https://photo-sphere-viewer.js.org/ now and it has fixed all the problems I was having with vrview. When you click on the photo, it tells you the coordinates you clicked (not the camera view), and more importantly, it works without a problem. The features are a lot more sophisticated than vrview, and all round better job done of it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants