Skip to content

Commit fa35756

Browse files
committed
fix: ui sizing in screen-based XR sessions
1 parent b0ea8fc commit fa35756

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/uikit/src/components/fullscreen.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ export class Fullscreen<
6262
batch(() => {
6363
if (camera instanceof PerspectiveCamera) {
6464
const cameraHeight = 2 * Math.tan((Math.PI * camera.fov) / 360) * distanceToCamera!
65-
this.pixelSize.value = cameraHeight / this.renderer.getSize(vectorHelper).y
65+
let pixelSize = cameraHeight / this.renderer.getSize(vectorHelper).y
66+
//if we are in a screen-based xr session, apply the pixel ratio to the pixel size to display the UI in the same size as outside of XR
67+
const xrSession = this.renderer.xr.getSession()
68+
if (xrSession?.interactionMode === 'screen-space') {
69+
pixelSize *= this.renderer.getPixelRatio()
70+
}
71+
this.pixelSize.value = pixelSize
6672
this.sizeY.value = cameraHeight
6773
this.sizeX.value = cameraHeight * camera.aspect
6874
}

0 commit comments

Comments
 (0)