Add uikit options for automatic @pmndrs/uikit renderer setup - #317
Conversation
| import 'xrblocks/addons/simulator/SimulatorAddons.js'; | ||
|
|
||
| import {reversePainterSortStable} from '@pmndrs/uikit'; | ||
| import * as uikit from '@pmndrs/uikit'; |
| options.simulator.instructions.enabled = false; | ||
| options.simulator.handPosePanel.enabled = false; | ||
| options.simulator.renderToRenderTexture = false; | ||
| options.uikit.enable(uikit); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I'm also ok with dynamic loading, or recommend user to enable uikit for complex ui?
There was a problem hiding this comment.
If it's ok with you, I prefer this method since it doesn't add a bunch of boilerplate into XR Blocks itself.
cb5f89a to
799dfb5
Compare
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);
```
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:
After: