Video as texture - again

Thank you, not sure if I follow (well, clearly I don’t:-) - ObjectRug and Object curtain are not the same object? So I’m trying to click on on the rug and on the curtain to swap the video texture on a material applied to a completely different (third) object…

Please see below the full script I’m using, sorry to be a pain…
Cheers
Wojtek

<script>
  const viewer = WALK.getViewer();

  viewer.setMaterialEditable('RugMaterial');
  
  function createVideoTexture(src, muted, loop) {
    const video = document.createElement('video');
    video.src = src;
    video.autoplay = false;
    video.muted = muted;
    video.loop = loop;
    return viewer.createTextureFromHtmlVideo(video);
  }
  
  function setUpExternalVideoTexture(triggerNodeTypeName, materialName,
                                     videoSrc, muted, loop) {
    let videoTexture = null;
    viewer.onNodeTypeClicked(triggerNodeTypeName, function() {
      // Create the video texture only once.
      if (!videoTexture) {
        videoTexture = createVideoTexture(videoSrc, muted, loop);
        const material = viewer.findMaterial(materialName);
        material.baseColorTexture = videoTexture;
      }
      if (!videoTexture.isPlaying) {
        videoTexture.play();
      } else {
        videoTexture.pause();
      }
      viewer.requestFrame();
      return true;
    });
  }

  setUpExternalVideoTexture('ObjectRug', 'RugMaterial', 'https://cdn0.shapespark.com/demo/ASSETS/textures/dots-video.mp4', false, true);

  setUpExternalVideoTexture('ObjectCurtain A', 'RugMaterial', 'https://cdn0.shapespark.com/demo/ASSETS/textures/lines-video.mp4', false, true);

</script>