Skip to content

Conversation

MiiBond
Copy link
Contributor

@MiiBond MiiBond commented Sep 25, 2025

@bghgary , here's a rough implementation of the extension that would enable OpenPBR per material. Feedback welcome.

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 25, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 25, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 26, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 26, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 26, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 26, 2025

@bghgary bghgary requested review from ryantrem and bghgary September 26, 2025 21:00
* @internal
*/
public _loadMaterialAsync(
private async _ensurePbrMaterialClassesAsync(): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a Lazy helper class now (added recently) that can be used for this type of thing. The Lazy instance can be created at loader construction time and then just accessed in _loadMaterialAsync. Up to you, but I suspect it would be a bit cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

public _loadMaterialAsync(
private async _ensurePbrMaterialClassesAsync(): Promise<void> {
if (!this._pbrMaterialClass || !this._pbrMaterialAdapterClass) {
const openpbrExt = this._extensions.find((extension) => extension.name === "KHR_materials_openpbr");
Copy link
Member

@ryantrem ryantrem Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this always be true since it is just checking if we have a loader extension for KHR_materials_openpbr (which we always would)? Should this instead be checking the glTF json, e.g.:

Suggested change
const openpbrExt = this._extensions.find((extension) => extension.name === "KHR_materials_openpbr");
const openpbrExt = this.isExtensionUsed("KHR_materials_openpbr");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._extensions appears to be the list of extensions used in the loading glTF, not a complete list of all extensions. So this seems to work fine.
However, your suggested code is certainly cleaner.

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 29, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 29, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants