pchen66 / panolens.js

Javascript panorama viewer based on Three.js
https://pchen66.github.io/Panolens/
MIT License
2.79k stars 498 forks source link

Get current center coordinates #379

Open aferrato opened 2 years ago

aferrato commented 2 years ago

Hello, I would like to obtain the coordinates of the current center of the image to be able to use them later.

Let me explain, I move the panoramic image and I choose the view I prefer, how can I get the coordinates of the central point of the view?

Practically the same that can be done by pressing Ctr and moving the mouse, but referring to the center of panolens-container div.

thank you.

e-pacciani commented 2 years ago

This is the method i wrot to get the center coordinates

export function getCameraCenterPosition(viewer: Viewer): Position {
  const position = viewer.raycaster.intersectObject(viewer.panorama, true)[0]
    .point;

  // intersectObject returns a negative x value so it must be set to the opposite to have the right x coordinate
  position.x = -position.x;

  return position;
}
CasperWind commented 2 years ago

hey @e-pacciani Where do i have to put your method? i have tryed some things but i can only get the coordinates from the mouse not the center.

hungvo2010 commented 1 year ago

Have someone find out the solution? Please help me

hungvo2010 commented 1 year ago

@pchen66