-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for material variants #4528
Conversation
Could you please add an overview of the new public API to the PR description. |
e5c7d06
to
632755d
Compare
} | ||
|
||
// reset material variants on entity | ||
_resetMaterialVariant(entity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd get rid of these _reset functions, as its the same code as the function above apart from the material selection - just make a small change to that function to handle it and remove the code duplication?
The API lives entirely in the GLB container, allowing the user to get the list of variants and apply it to a mesh. The variants are parsed, and the data for the variants are stored on the resource level of the container, thus avoiding any intrusion into any engine types.
…he material itself.
…rnally, as well as debug warn if the variant can't be found.
…riant is applied as well. Also fixed lint.
Also provide documentation clarifying that the name is optional, and if not provided resets the material variants.
const meshVariants = this.data.meshVariants[instance.mesh.id]; | ||
if (meshVariants) { | ||
instance.material = this.data.materials[meshVariants[variant]]; | ||
Debug.assert(instance.material); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you could move the assert outside of if/else, so that it validates both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved with a single small comment.
4c970f1
to
10c8224
Compare
Description
Adds support for KHR_materials_variants as well as provides an API for changing the material. Also fixes the default material index ownership, having them live in the container instead of on the mesh.
Fixes #3647
API changes