Skip to content

Commit 2d13cb7

Browse files
Use the right camera to position menupanel in xr (#5048)
* use the right camera to position xrmenu
1 parent 4f51296 commit 2d13cb7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import {Box3, BufferGeometry, Event as ThreeEvent, EventDispatcher, Line, Matrix4, PerspectiveCamera, Quaternion, Vector3, WebGLRenderer, XRControllerEventType, XRTargetRaySpace, Object3D} from 'three';
16+
import {Box3, BufferGeometry, Camera, Event as ThreeEvent, EventDispatcher, Line, Matrix4, PerspectiveCamera, Quaternion, Vector3, WebGLRenderer, XRControllerEventType, XRTargetRaySpace, Object3D} from 'three';
1717
import {XREstimatedLight} from 'three/examples/jsm/webxr/XREstimatedLight.js';
1818

1919
import {CameraChangeDetails, ControlsInterface} from '../features/controls.js';
@@ -302,14 +302,14 @@ export class ARRenderer extends EventDispatcher<
302302
if (this.xrMode !== 'screen-space') {
303303
this.menuPanel = new XRMenuPanel();
304304
scene.add(this.menuPanel);
305-
this.updateMenuPanelPosition(scene.camera, this.placementBox!); // Position the menu panel
305+
this.updateMenuPanelPosition(scene.getCamera(), this.placementBox!); // Position the menu panel
306306
}
307307

308308
this.lastTick = performance.now();
309309
this.dispatchEvent({type: 'status', status: ARStatus.SESSION_STARTED});
310310
}
311311

312-
private updateMenuPanelPosition(camera: PerspectiveCamera, placementBox: PlacementBox) {
312+
private updateMenuPanelPosition(camera: Camera, placementBox: PlacementBox) {
313313
if (!this.menuPanel || !placementBox) {
314314
return;
315315
}
@@ -551,7 +551,7 @@ export class ARRenderer extends EventDispatcher<
551551
}
552552
this.menuPanel = new XRMenuPanel();
553553
this.presentedScene!.add(this.menuPanel);
554-
this.updateMenuPanelPosition(this.presentedScene!.camera, this.placementBox!);
554+
this.updateMenuPanelPosition(this.presentedScene!.getCamera(), this.placementBox!);
555555
}
556556

557557
};
@@ -1053,7 +1053,7 @@ export class ARRenderer extends EventDispatcher<
10531053
if (menuPanel) {
10541054
menuPanel.updateOpacity(delta);
10551055
// Update menu panel position whenever the model moves
1056-
this.updateMenuPanelPosition(scene.camera, box);
1056+
this.updateMenuPanelPosition(scene.getCamera(), box);
10571057
}
10581058
}
10591059

0 commit comments

Comments
 (0)