Skip to content

Commit e1c7ca6

Browse files
tbirdsofloryst
authored andcommitted
perf(WebXR): Unify WebXR scene default physical factors
Updates default WebXR scene factors to standardize across VR and AR experiences. Factors are selected to scale and translate the default scene so that VR and AR example datasets can be viewed comfortably. Previous behavior resulted in VR models appearing very large and very close to the user's face, which was particularly uncomfortable in testing on the HoloLens 2 headset. In updated behavior the examples in `GeometryViewer` and `WebXRVolume` appear smaller and at a comfortable distance from the user.
1 parent 20c6c59 commit e1c7ca6

File tree

1 file changed

+6
-32
lines changed
  • Sources/Rendering/OpenGL/RenderWindow

1 file changed

+6
-32
lines changed

Sources/Rendering/OpenGL/RenderWindow/index.js

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ const SCREENSHOT_PLACEHOLDER = {
2626
};
2727

2828
const DEFAULT_RESET_FACTORS = {
29-
vr: {
30-
rescaleFactor: 1.0,
31-
translateZ: -0.7, // 0.7 m forward from the camera
32-
},
33-
ar: {
34-
rescaleFactor: 0.25, // scale down AR for viewing comfort by default
35-
translateZ: -0.5, // 0.5 m forward from the camera
36-
},
29+
rescaleFactor: 0.25, // isotropic scale factor reduces apparent size of objects
30+
translateZ: -1.5, // default translation initializes object in front of camera
3731
};
3832

3933
function checkRenderTargetSupport(gl, format, type) {
@@ -371,30 +365,10 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
371365
};
372366

373367
publicAPI.resetXRScene = (
374-
inputRescaleFactor = DEFAULT_RESET_FACTORS.vr.rescaleFactor,
375-
inputTranslateZ = DEFAULT_RESET_FACTORS.vr.translateZ
368+
rescaleFactor = DEFAULT_RESET_FACTORS.rescaleFactor,
369+
translateZ = DEFAULT_RESET_FACTORS.translateZ
376370
) => {
377371
// Adjust world-to-physical parameters for different modalities
378-
// Default parameter values are for HMD VR
379-
let rescaleFactor = inputRescaleFactor;
380-
let translateZ = inputTranslateZ;
381-
382-
const isXrSessionAR = [
383-
XrSessionTypes.HmdAR,
384-
XrSessionTypes.MobileAR,
385-
].includes(model.xrSessionType);
386-
if (
387-
isXrSessionAR &&
388-
rescaleFactor === DEFAULT_RESET_FACTORS.vr.rescaleFactor
389-
) {
390-
// Scale down by default in AR
391-
rescaleFactor = DEFAULT_RESET_FACTORS.ar.rescaleFactor;
392-
}
393-
394-
if (isXrSessionAR && translateZ === DEFAULT_RESET_FACTORS.vr.translateZ) {
395-
// Default closer to the camera in AR
396-
translateZ = DEFAULT_RESET_FACTORS.ar.translateZ;
397-
}
398372

399373
const ren = model.renderable.getRenderers()[0];
400374
ren.resetCamera();
@@ -403,9 +377,9 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
403377
let physicalScale = camera.getPhysicalScale();
404378
const physicalTranslation = camera.getPhysicalTranslation();
405379

380+
const rescaledTranslateZ = translateZ * physicalScale;
406381
physicalScale /= rescaleFactor;
407-
translateZ *= physicalScale;
408-
physicalTranslation[2] += translateZ;
382+
physicalTranslation[2] += rescaledTranslateZ;
409383

410384
camera.setPhysicalScale(physicalScale);
411385
camera.setPhysicalTranslation(physicalTranslation);

0 commit comments

Comments
 (0)