Material texture change not working anymore #3790
Unanswered
plutorkhan
asked this question in
Q&A
Replies: 3 comments 2 replies
-
I couldn't put html in description. Though you can easily check the code in the link from chrome dev tools |
Beta Was this translation helpful? Give feedback.
0 replies
-
It sounds like you should probably pin the version of MV you're using, until you can update to |
Beta Was this translation helpful? Give feedback.
0 replies
-
Also, the real problem was an accidental push of a pre-release of v2.0 to unpkg, which has since been corrected: #3780. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The material change which i did through scene graph is not working anymor. When changing color the spa cabinet color should be changed as well by applying jpg texture to the material. It was working for months and no change has been made to the code, suddenly it stopped working.
Code:
Html: `
Javascript:
<script type="module"> const modelViewerTexture = document.querySelector("model-viewer"); customElements.get("model-viewer").minimumRenderScale = 1; modelViewerTexture.addEventListener("scene-graph-ready", (ev) => { let material = modelViewerTexture.model.materials[17]; let water = modelViewerTexture.model.materials[15]; document.querySelectorAll('.colorPicker').forEach(e => { e.addEventListener('click', (event) => { material.pbrMetallicRoughness.baseColorTexture.texture.source.setURI(event.target.name); }); }) let checkbox = document.querySelector('input[type="checkbox"]'); document.querySelectorAll('#switchWater').forEach(e => { e.addEventListener('change', (event) => { if (checkbox.checked) { water.pbrMetallicRoughness.setBaseColorFactor([1, 1, 1, 1]); modelViewerTexture.setAttribute("ios-src", "dre1600-2cl-water.usdz"); console.log('Checked'); } else { // do that water.pbrMetallicRoughness.setBaseColorFactor([1, 1, 1, 0]); modelViewerTexture.setAttribute("ios-src", "dre1600-2cl-dry.usdz"); } }); }) document.querySelector("#controls").addEventListener('beforexrselect', (ev) => { ev.preventDefault(); }); }) </script>Live Demo
https://imajinn.live/models/foxspa/dre-1600-2cl/index.html
Version
https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js
Browser Affected
OS
AR
Beta Was this translation helpful? Give feedback.
All reactions