Back to the Shapespark home page

2 actions on one click

Hello, I wanted to know if I can use two actions, place a view and play a video that I have as a texture…
is it possible, and what would be the code?

WALK.getViewer().switchToView(“myscene”);

and…?

thank you!

Try something like this:

 var viewer = WALK.getViewer();
 viewer.setMaterialEditable('NAME-OF-YOUR-MATERIAL-WITH-VIDEO');
 viewer.onViewSwitchDone(function(viewName) {
   var videoTexture = viewer.findMaterial('NAME-OF-YOUR-MATERIAL-WITH-VIDEO').baseColorTexture;
   if (viewName === 'myscene') {
     // Play the video after switching to the view 'myscene'
     videoTexture.isPlaying = true;
   } else {
     // And pause it after switching to any other view.
     videoTexture.isPlaying = false;
   }
 });
1 Like