-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to change glb model material color at runtime? #292
Comments
I think you could look at this (to get a general idea) and also peak into the implementation of
The main idea is to select the correct entity, get the material and change its attributes (I think you also need to reapply the material then, let me double check on that …) |
See this for reference, you can also get the entity from an const { renderableManager } = useFilamentContext()
const entity = asset.getFirstEntityByName("yourEntitysNameSeeDocLinkIShared")
// There is probably just one material, otherwise check which index to select
renderableManager.getMaterialInstanceAt(entity, 0).setFloat4Parameter('baseColorFactor', [1, 1, 1, 1]) // in sRGB |
Ideally we would like to expose a declarative react API for this, probably in EntitySelector. Would def appreciate a PR for this (should be javacsript/typescript changes only!) |
Thank you, appreciated. I'll try to create a PR for this. |
Hi, I'm trying to change the color of a
glb
model's material at runtime using react-native-filament, but I'm having trouble figuring out how to do it. There issetDefaultFloat4Parameter
method ofMaterial
interface in the docs. I just can’t figure out how to access Material.The text was updated successfully, but these errors were encountered: