SDK Bug Reproduction Template

by Jowed

HTML

<head>
  <script src="https://static.matterport.com/showcase-sdk/2.0.1-0-g64e7e88/sdk.js"></script>
</head>
<body>
  <div class="container">
    <iframe id="showcase-iframe" allow='xr-spatial-tracking; fullscreen' frameborder='0'></iframe>
  </div>
</body>

CSS

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.container{
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-flow: column nowrap
}
#showcase-iframe{
  width: 100%;
  height: 100%;
}

JavaScript

const key = "6eb9607db19546aebe10dce90aa001fa" // jsfiddle key
const modelSid = "iL4RdJqi2yK"; // change to custom model SID
const urlParameters = "&play=1&qs=1";

const iframe = document.getElementById('showcase-iframe')
function connect() {
	window.MP_SDK.connect(iframe, key, '3.8')
    .then(loadedShowcaseHandler, console.error);
}
iframe.onload = connect;
iframe.src = `https://my.matterport.com/show/?m=${modelSid}${urlParameters}`;

function loadedShowcaseHandler(mpSdk) {
	console.debug("Connected to the SDK");
  recreateIssue(mpSdk);
}

function recreateIssue(mpSdk){
	// Recreate the issue here
	console.log("Hola");
  
  console.log('getting mattertags');
            
  mpSdk.Mattertag.getData()
    .then(function(mattertags) {

    for (i=0; i < mattertags.length; i++) {
      element = mattertags[i];
      console.log(element.label);
          
      // find_label = 'Watercolor';
      // find_label = 'Altman';
      find_label = 'Wolf Range'; // it's the last mattertag label
      
      if( element.label.indexOf(find_label) != -1 )
      {
        console.log("===> "+find_label+" found :: editOpacity = 1 ");
        mpSdk.Mattertag.editOpacity(element.sid, 1);
      }
      else
      {
        mpSdk.Mattertag.editOpacity(element.sid, 0);
        console.log("===> "+find_label+" NOT found :: editOpacity = 0 ");
      }
    }

  })
    .catch(function(error) {
    // console.log('mattertags getData', error);
    return false;
  });	
                
}