I’m very new to html, css and javascript. So basically I have a page to display 360 panorama images, and I want the picture to change when I click on a button. For example I have button 1 to display image1, and button 2 to display image2.
What I’ve tried is to create a button on html file:
<button onclick="functionName(insertedName.value)">Image1</button>
and call the function on js file:
function functionName(){
const panoramaImage = new PANOLENS.ImagePanorama("images/image3.jpg");
const imageContainer = document.querySelector(".image-container");
const viewer = new PANOLENS.Viewer({
container: imageContainer,
});
viewer.add(panoramaImage);
}
But this doesn’t seem to work, do I misunderstand anything because I’m very new. Any help and explanation would help a lot, thanks!
2
Answers
Having never used Panlolens it took a bit of time to figure out a method of changing the loaded panorama image and even now I don’t know if it is the best approach.
As you have only two images of known names my approach was to load the paths of both images into an array so that a simple 1 or 0 could be used to select an image via the assigned
dataset
attribute on the button itself. There are other ways to do this.