mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.16k stars 712 forks source link

Generating Thumbnail on specific yaw and hfov #1078

Closed tokidoki11 closed 2 years ago

tokidoki11 commented 2 years ago

Hi, I would like to create a thumbnail image on specific yaw and hfov

I'm thinking of 2 ideas

  1. Getting the center tile the yaw and hfov.
    • Is there any function to know what is the tile of the yaw and hfov ?
  2. Getting the rendering canvas, export it as dataURL(toDataURL('png')) (preffered)
    • I tried this on canvas inside .pnlm-render-container
    • when exported, I only get black image. Is there any reason behind this?
samedadl commented 2 years ago

I can suggest a way for step one, but I'm not sure if this is exactly what you want. getYaw() function to know what is the title of the yaw.

viewer.on('mousedown', function (event) {
      // For pitch and yaw of center of viewer
      yaw = viewer.getYaw()
      pitch = viewer.getPitch()
      console.log(yaw, pitch)
      // For pitch and yaw of mouse location
      console.log(viewer.mouseEventToCoords(event));
    });
mpetroff commented 2 years ago
  1. Getting the center tile information isn't going to help you, since unless the center of the view happens to be at the center of a cube face, the tile will be distorted.
  2. This has been asked and answered multiple times. See, e.g., https://github.com/mpetroff/pannellum/issues/1042#issuecomment-948136831 or https://github.com/mpetroff/pannellum/issues/680#issuecomment-435078166.
tokidoki11 commented 2 years ago

@mpetroff Thank you for the answer I will try it, will close this issue