Skip to content

Commit

Permalink
Add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-MSFT committed Mar 4, 2022
1 parent c4165a2 commit 236017e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/XR/features/WebXRImageTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Observable } from "../../Misc/observable";
import { WebXRAbstractFeature } from "./WebXRAbstractFeature";
import { Matrix } from "../../Maths/math.vector";
import { Nullable } from "../../types";
import { Tools } from "../../Misc/tools";

declare const XRImageTrackingResult: XRImageTrackingResult;

Expand Down Expand Up @@ -179,18 +180,24 @@ export class WebXRImageTracking extends WebXRAbstractFeature {
}
});

const images = await Promise.all(promises);
try
{
const images = await Promise.all(promises);

this._originalTrackingRequest = images.map((image, idx) => {
return {
image,
widthInMeters: this.options.images[idx].estimatedRealWorldWidth,
};
});

this._originalTrackingRequest = images.map((image, idx) => {
return {
image,
widthInMeters: this.options.images[idx].estimatedRealWorldWidth,
trackedImages: this._originalTrackingRequest,
};
});

return {
trackedImages: this._originalTrackingRequest,
};
} catch (ex) {
Tools.Error("Error loading images for tracking, WebXRImageTracking disabled for this session.");
return {};
}
}

protected _onXRFrame(_xrFrame: XRFrame) {
Expand Down

0 comments on commit 236017e

Please sign in to comment.