Skip to content

Add uikit options for automatic @pmndrs/uikit renderer setup - #317

Merged
dli7319 merged 1 commit into
google:mainfrom
dli7319:uikit
Jun 1, 2026
Merged

Add uikit options for automatic @pmndrs/uikit renderer setup#317
dli7319 merged 1 commit into
google:mainfrom
dli7319:uikit

Conversation

@dli7319

@dli7319 dli7319 commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Introduces the UIKitOptions class that automatically configures Three.js's WebGLRenderer when @pmndrs/uikit is enabled (setting localClippingEnabled to true and registering reversePainterSortStable as the custom transparent sort). This also sets the stage to make uikit available to internal XR Blocks components in the future.

Before:

import {reversePainterSortStable} from '@pmndrs/uikit';
// ...
await xb.init(options);
const renderer = xb.core.renderer;
renderer.localClippingEnabled = true;
renderer.setTransparentSort(reversePainterSortStable);

After:

import * as uikit from '@pmndrs/uikit';
// ...
options.uikit.enable(uikit);
await xb.init(options);

import 'xrblocks/addons/simulator/SimulatorAddons.js';

import {reversePainterSortStable} from '@pmndrs/uikit';
import * as uikit from '@pmndrs/uikit';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@qxziuan please discuss with @dli7319 regarding this change

options.simulator.instructions.enabled = false;
options.simulator.handPosePanel.enabled = false;
options.simulator.renderToRenderTexture = false;
options.uikit.enable(uikit);

@qxziuan qxziuan May 29, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My thoughts, open to discussion.

If we already know we depend on uikit, do we need this option?

Or logically, if only when we want to use uiblocks do we need uikit, then can we set something like options.ui.backend = ‘uiblocks’ (or default) and we set uikit dependencies accordingly. I feel the xrblocks options doesn’t need to have knowledge about uikit, but just what ui it uses. Then the ui manages the dependencies.

In the future when we fully move to uiblocks we can then delete this flag.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm trying to move these two lines from the app into XR Blocks.

renderer.localClippingEnabled = true;
renderer.setTransparentSort(reversePainterSortStable);

XR Blocks doesn't have a hard dependency on UI Blocks so we don't already know if it's available ahead of time. Alternatively, XR Blocks could try to detect it with a dynamic import. But this leaves the option out of the user's control.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Got it.

@ruofeidu ruofeidu May 30, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm also ok with dynamic loading, or recommend user to enable uikit for complex ui?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If it's ok with you, I prefer this method since it doesn't add a bunch of boilerplate into XR Blocks itself.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sgtm

@dli7319
dli7319 force-pushed the uikit branch 2 times, most recently from cb5f89a to 799dfb5 Compare June 1, 2026 15:33
Introduces the UIKitOptions class that automatically configures Three.js's WebGLRenderer when @pmndrs/uikit is enabled (setting localClippingEnabled to true and registering reversePainterSortStable as the custom transparent sort). This also sets the stage to make uikit available to internal XR Blocks components in the future.

Before:
```javascript
import {reversePainterSortStable} from '@pmndrs/uikit';
// ...
await xb.init(options);
const renderer = xb.core.renderer;
renderer.localClippingEnabled = true;
renderer.setTransparentSort(reversePainterSortStable);
```

After:
```javascript
import * as uikit from '@pmndrs/uikit';
// ...
options.uikit.enable(uikit);
await xb.init(options);
```
@dli7319
dli7319 merged commit e19b010 into google:main Jun 1, 2026
8 checks passed
@dli7319
dli7319 deleted the uikit branch June 1, 2026 21:48
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