Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A proposal that allows an alternate approach to extending built-in materials. Only the core change is present in this PR.
Some examples are made in #14206, click on the images to see the demos.
Use this API in

GLTFLoaderto extend theStandardMaterialwith spec/gloss model. And then in the actual loader example, make an "inline" extension for simple instancing (instancing_lambertexample). The goal is to have two completely agnostic extensions that just work together - the instancing is applied to an arbitrary material, while the spec/gloss is intended solely forStandardMaterial.Combine three different extensions (simple instancing, per map uv channels and spec/gloss) on a single material, and modify one of the extensions "inline" (use the instancing offset, but animate the scale effect in the shader). The demo uses a refactored GLTFLoader that just calls one of these decorators, the rest are applied in the inline demo code.


Individually these can be done with
onBeforeCompile, butonBeforeCompilemay possibly have issues. The name might be better asonBeforeParseoronWillRefresh. Combining these is a challenge with it though, while this API may be more flexible, if not the friendliest one.Per map transforms with
onBeforeCompile.Instancing lambert refactored with
onBeforeCompileStandard/gloss refactor with
onBeforeCompile.This should be decoupled from
/examples/nodesand not be blocked by it. Thank you.