mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.

Home Page:https://pannellum.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mouse click to cube coordinates

StephenWitherden opened this issue · comments

Hi, there, thank you for this awesome library.

I am working to include a depth map for measurement purposes. Effectively, what I want to implement is your suggestion in #1128 but using a cube map rather than the equirectangular image. I am also aware that getting from mouse coordinates to equirectangular coordinates is trivial as you say in #765.

Should I just go the equirectangular route, or is there a nice neat algorithm I could use to map a mouse click to coordinates on a multidimensional cube map? I am preferring cubes because of performance on large panoramas.

This Stack Exchange answer describes how to go from latitude / longitude to cube face coordinates (in C#, but it's straightforward to convert to JavaScript):
https://gamedev.stackexchange.com/a/137303

The pitch / yaw returned by mouseEventToCoords is equivalent to latitude / longitude. It might take some trial and error to get the face mapping and coordinate signs correct, but that should get you started.