Web scene - slide tour

This sample demonstrates how to create an animated tour of the slides in a WebScene by using the applyTo() method. applyTo() returns a promise that resolves after the slide has been applied to the view. By chaining the applyTo() method of the slides, we can play through all the slides without user input.

The chaining is done with a recursive function:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// slides  is the array of slides from the webscene
const slides = scene.presentation.slides;

function goToSlide(i) {
  const slide = slides.getItemAt(i);

  if (i < slides.length) {
    infoDiv.innerHTML = slide.title.text;
    // call the applyTo method on the current slide
    slide
      .applyTo(view, { duration: 3000 })
      // and after the slide was applied to the view wait for 8 seconds
      // and then call goToSlide for the next slide
      .then(() => {
        window.setTimeout(() => {
          goToSlide(i + 1);
        }, 8000);
      });
  }
}

// go to the first slide - this function triggers the chaining
goToSlide(1);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.