three.js icon indicating copy to clipboard operation
three.js copied to clipboard

GLTFLoader: Make KHR_materials_unlit able to be overridden

Open 0b5vr opened this issue 5 years ago • 5 comments
trafficstars

Will close #20709

What I did

  • Replaced hardcoded behavior of KHR_materials_unlit with plugin system introduced in #19144 .
    • Current behavior completely ignores getMaterialType and extendMaterialParams of any plugin when KHR_materials_unlit exists in a material.
  • GLTFLoader.register now registers the given plugin callback to the top of its plugin callback list instead of last.
    • Which means, GLTFLoader's plugin system now prioritizes user defined plugins than builtin ones.

Motivation

As I mentioned in #20709, I want to load our own custom glTF material using GLTFLoader. However, the glTF still have KHR_materials_unlit as a fallback, which is prioritized than any plugins registered. With these changes, I can override the behavior of KHR_materials_unlit.

Points need review

  • GLTFMaterialsUnlitExtension.extendMaterialParams , does the "Removing material params" part look good?
  • There still are parts that says materialType !== MeshBasicMaterial . I don't know how I can resolve this

0b5vr avatar Nov 20 '20 07:11 0b5vr

Redone the commits against the latest dev , plus applied the changes also to examples/js/

0b5vr avatar Feb 10 '21 04:02 0b5vr

ping @donmccurdy @takahirox , how do you think about it? See the "Points need review" section on the description.

0b5vr avatar Feb 10 '21 05:02 0b5vr

Update! Thanks to #21207 I'm now able to remove KHR_materials_unlit in beforeRoot of the plugin that want to override the unlit, my demand is achieved. This PR still have a value I think though.

Ping @donmccurdy @takahirox

0b5vr avatar Mar 09 '21 04:03 0b5vr

Sorry for the delay – this looks good to me (after rebase) if @takahirox does not have any concerns!

donmccurdy avatar Aug 06 '21 16:08 donmccurdy

Ah sorry, I didn't notice the PR. Would you please resolve the conflicts? And then I will test and review.

takahirox avatar Aug 06 '21 16:08 takahirox

@0b5vr is this PR still something you're interested in having merged?

donmccurdy avatar Oct 14 '22 14:10 donmccurdy

Closing. Seems the change is not required anymore.

Mugen87 avatar Nov 21 '22 10:11 Mugen87