Test: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 17: | Line 17: | ||
<html> | <html> | ||
<script type="module"> | <script type="module"> | ||
<nowiki> | |||
const modelViewer = document.getElementById('bearModelViewer'); | const modelViewer = document.getElementById('bearModelViewer'); | ||
const bearTextureSelector = document.getElementById('bearTexture'); | const bearTextureSelector = document.getElementById('bearTexture'); | ||
Line 77: | Line 42: | ||
// Attempt to get the first material from the loaded model. | // Attempt to get the first material from the loaded model. | ||
// Most simple GLB models have a single primary material. | // Most simple GLB models have a single primary material. | ||
if (modelViewer.model && modelViewer.model.materials.length > 0) { | if (modelViewer.model && modelViewer.model.materials.length > 0) { // THIS LINE IS NOW PROTECTED | ||
mainModelMaterial = modelViewer.model.materials[0]; | mainModelMaterial = modelViewer.model.materials[0]; | ||
console.log('Identified main model material:', mainModelMaterial); | console.log('Identified main model material:', mainModelMaterial); | ||
Line 154: | Line 119: | ||
} | } | ||
}); | }); | ||
</nowiki> | |||
</script> | </script> | ||
</html> | </html> |