Closed literallylara closed 1 month ago
Thank you for the detailed repro steps - this is clearly a bug. It even repros on the editor; only the first variant is editable. I swear this used to work, so this may be a regression - time to add some more tests.
Gotcha, do you happen to know which versions are likely to be unaffected or where it's best to look if I want to give fixing it a try? 🙂
Upon further investigation, this was missed because it only repros on models with certain combinations of properties. Basically we're using GLTFLoader
's applyFinalMaterial()
incorrectly - it's a bit ugly, so I'll go ahead and take care of refactoring it. I really appreciate the offer though!
Description
When a variant is selected, any update on materials belonging to the variant seem to have no effect in the viewer. Is this intended behavior? If so I would expect the API to throw an error or a warning. My client offers customizable products which are set up with variants but certain parts on the model need to change (e.g. a customer-provided artwork). I tried to track down the issue in the code and think it might be related to this line but I am not sure: https://github.com/google/model-viewer/blob/2edbce11fecee779a8f5abd46b2f796512fe7014/packages/model-viewer/src/three-components/GLTFInstance.ts#L169
Steps to reproduce:
beach
variant$el = document.querySelector('#variants model-viewer')
(or via inspector)m = $el.model.materials.find(v => v.hasVariant('beach'))
m.isActive
(should reporttrue
)m.pbrMetallicRoughness.roughnessFactor
(will report1
)m.pbrMetallicRoughness.setRoughnessFactor(0)
m.pbrMetallicRoughness.roughnessFactor
(will report0
)Version
Browser Affected
OS