mpetroff / pannellum

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

How to use javascript to add new hot spots? #1166

Open yongliancai opened 1 year ago

yongliancai commented 1 year ago

I want to use javascript to add new hot spots, and can add it pitch yaw text in web How can I do?

mpetroff commented 1 year ago

The addHotSpot method is what you're looking for. If you create your viewer with var viewer = pannellum.viewer(...);, you can add a hot spot to the current scene with

viewer.addHotSpot({
    "pitch": 10,
    "yaw": 10,
    "type": "info",
    "text": "some text here"
});

If you want to add it to a different scene, you can provide the scene ID as the second argument to the method.

guohuayu commented 1 year ago

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'push')