Skip to content

Commit 4f51296

Browse files
add xrmenupanel only in xr, avoid ar (#5040)
1 parent 48cd1de commit 4f51296

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

packages/model-viewer/src/three-components/ARRenderer.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,11 @@ export class ARRenderer extends EventDispatcher<
299299
new PlacementBox(scene, this.placeOnWall ? 'back' : 'bottom');
300300
this.placementComplete = false;
301301

302-
this.menuPanel = new XRMenuPanel();
303-
scene.add(this.menuPanel);
304-
this.updateMenuPanelPosition(scene.camera, this.placementBox!); // Position the menu panel
305-
302+
if (this.xrMode !== 'screen-space') {
303+
this.menuPanel = new XRMenuPanel();
304+
scene.add(this.menuPanel);
305+
this.updateMenuPanelPosition(scene.camera, this.placementBox!); // Position the menu panel
306+
}
306307

307308
this.lastTick = performance.now();
308309
this.dispatchEvent({type: 'status', status: ARStatus.SESSION_STARTED});
@@ -543,13 +544,15 @@ export class ARRenderer extends EventDispatcher<
543544
this.placementBox = new PlacementBox(
544545
this.presentedScene!, this.placeOnWall ? 'back' : 'bottom');
545546
}
546-
if (this.menuPanel) {
547-
this.menuPanel.dispose(); // Add a dispose method to XRMenuPanel if needed
548-
this.menuPanel = null;
549-
}
550-
this.menuPanel = new XRMenuPanel();
551-
this.presentedScene!.add(this.menuPanel);
552-
this.updateMenuPanelPosition(this.presentedScene!.camera, this.placementBox!);
547+
if (this.xrMode !== 'screen-space') {
548+
if (this.menuPanel) {
549+
this.menuPanel.dispose();
550+
this.menuPanel = null;
551+
}
552+
this.menuPanel = new XRMenuPanel();
553+
this.presentedScene!.add(this.menuPanel);
554+
this.updateMenuPanelPosition(this.presentedScene!.camera, this.placementBox!);
555+
}
553556

554557
};
555558

0 commit comments

Comments
 (0)