googlearchive / vrview

Library for embedding immersive media into traditional websites.
http://developers.google.com/cardboard/vrview
Apache License 2.0
1.71k stars 1.09k forks source link

Best way to get yaw/pitch at mouse pointer? #230

Open graymouser opened 7 years ago

graymouser commented 7 years ago

Similar to #203 , trying to implement a 'click to add hotspot' interface and getting mouse yaw/pitch on click would be super helpful, whether via modified getPosition or a separate function.

Does anyone know a three.js command sequence that would work this out from worldRenderer.hotspotRenderer.pointer or similar? Have been fiddling with it but so far no luck, any help much appreciated.

WojciechJasinski commented 6 years ago

As far as I can see onGetPosition https://github.com/googlevr/vrview/blob/4545ce06e42987c4d118746a2e0a8fd880ed2cae/src/embed/main.js#L357-L364

returns somethig called camera rotation. The problem is that when I new hotspot whit Yaw and Pitch values returned by this method I get new hotspot rendered in very wrong position (90 degrees to the left). Furthermore loading pano I suspect that camera looks at Vector3(0, 0, 0) but in fact it looks at point 90 degrees to the right.

WojciechJasinski commented 6 years ago

I've also tried to send position using this.pointer on mouse up but still no effect:

  // If no hotspots are pressed, emit an empty click event.
  if (Util.isEmptyObject(this.downHotspots)) {
    this.emit('click');
    console.log('mouse up');
    console.log(this.pointer);
      Util.sendParentMessage({
          type: 'getposition',
          data: {
              x: this.pointer.x,
              y: this.pointer.y,
              z: -1, // skip
              add: true // add new hotspot if true
          }
      });
    return;
  }