Skip to content

OpenPBR toggle in Sandbox#18251

Open
MiiBond wants to merge 3 commits intoBabylonJS:masterfrom
MiiBond:mbond/sandbox-openpbr-toggle
Open

OpenPBR toggle in Sandbox#18251
MiiBond wants to merge 3 commits intoBabylonJS:masterfrom
MiiBond:mbond/sandbox-openpbr-toggle

Conversation

@MiiBond
Copy link
Copy Markdown
Contributor

@MiiBond MiiBond commented Apr 7, 2026

Here's a quick idea of how to add a toggle to the Sandbox to load glTF files with the OpenPBRMaterial instead of the PBRMaterial.

  • Button can be toggled before an asset loads or after.
  • The current asset will reload when the toggle changes.
  • The previous state is saved in local storage.
  • The current icon is programmer art. Sorry. OpenPBR does have an official logo so one could be made in the Babylon style.

@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 8, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

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
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18251/merge/testResults/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

Snapshot stored with reference name:
refs/pull/18251/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18251/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18251/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18251/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18251/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18251/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18251/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18251/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18251/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18251/merge/?snapshot=refs/pull/18251/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@sebavan
Copy link
Copy Markdown
Member

sebavan commented Apr 8, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18251/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18251/merge/?snapshot=refs/pull/18251/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18251/merge/testResults/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an OpenPBR toggle to the Babylon.js Sandbox so glTF assets can be (re)loaded using OpenPBRMaterial via the glTF loader’s useOpenPBR flag, with the preference persisted in local storage.

Changes:

  • Persist OpenPBR mode in local storage and initialize GlobalState.useOpenPBR from it on startup.
  • Add a footer toggle button (with active styling) that flips OpenPBR mode and triggers a scene reload.
  • Wire GlobalState.useOpenPBR into GLTFFileLoader.useOpenPBR during plugin activation.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/tools/sandbox/src/tools/localStorageHelper.ts Adds SetUseOpenPBR / GetUseOpenPBR persistence helpers.
packages/tools/sandbox/src/sandbox.tsx Initializes useOpenPBR from local storage at app startup.
packages/tools/sandbox/src/img/icon-openpbr.png Adds the OpenPBR toggle icon asset.
packages/tools/sandbox/src/globalState.ts Adds useOpenPBR state and onRequestSceneReload observable.
packages/tools/sandbox/src/custom.d.ts Adds TS module declarations for .scss and .png imports.
packages/tools/sandbox/src/components/renderingZone.tsx Adds reload helper, listens for reload requests, and sets loader.useOpenPBR.
packages/tools/sandbox/src/components/footerButton.tsx Supports an active state for toggle-style buttons.
packages/tools/sandbox/src/components/footer.tsx Adds the OpenPBR toggle button and persists/requests reload on change.

Comment on lines +456 to +461
public override componentWillUnmount(): void {
if (this._onRequestSceneReloadObserver) {
this.props.globalState.onRequestSceneReload.remove(this._onRequestSceneReloadObserver);
this._onRequestSceneReloadObserver = null;
}
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

componentWillUnmount cleans up the onRequestSceneReload observer, but initEngine() also registers window-level resize and keydown listeners that aren’t removed. If this component is ever unmounted/remounted (e.g., hot reload), those handlers will accumulate and can cause duplicate reload/resize behavior; consider storing the handler functions and removing them here as well.

Copilot uses AI. Check for mistakes.
@ryantrem
Copy link
Copy Markdown
Member

ryantrem commented Apr 8, 2026

Inspector has gltf loader options. Is it sufficient to just add the OpenPBR option rather than making changes to Sandbox?
image

@ryantrem
Copy link
Copy Markdown
Member

ryantrem commented Apr 8, 2026

I added missing options (include useOpenPBR in this PR: #18262

@MiiBond
Copy link
Copy Markdown
Contributor Author

MiiBond commented Apr 10, 2026

I added missing options (include useOpenPBR in this PR: #18262

Thanks, @ryantrem. It would be nice if it were more persistent. The toggle is lost if I reload or drag in a new IBL.

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.

6 participants