Last active
November 27, 2020 07:24
-
-
Save wrr/822605c2bb581e75bb2cecfc72fe27d5 to your computer and use it in GitHub Desktop.
Detect which material was selected by the user and show the material name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
#banner { | |
position: absolute; | |
top: 30px; | |
text-align: center; | |
font-size: 3em; | |
width: 100%; | |
z-index: 10; | |
visibility: hidden | |
} | |
</style> | |
<div id="banner"></div> | |
<script> | |
(function() { | |
var messageId = 0; | |
function hideBanner(bannerElement, messageIdArg) { | |
return function() { | |
// Hide the message only if it wasn't replaced with a new one. | |
if (messageId === messageIdArg) { | |
bannerElement.style.visibility = 'hidden'; | |
} | |
} | |
} | |
function showMessage(message) { | |
var bannerElement = document.getElementById('banner'); | |
bannerElement.textContent = message; | |
bannerElement.style.visibility = 'visible'; | |
messageId += 1; | |
setTimeout(hideBanner(bannerElement, messageId), 4000); | |
} | |
var viewer = WALK.getViewer(); | |
viewer.onSceneReadyToDisplay(function() { | |
var setMaterialForMeshOriginal = viewer.setMaterialForMesh; | |
viewer.setMaterialForMesh = function(material, node) { | |
setMaterialForMeshOriginal.apply(this, [material, node]); | |
showMessage('material: ' + material.name); | |
} | |
}); | |
}()); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment