Skip to content

Commit

Permalink
improve: move xr init to infrastructure (#12765)
Browse files Browse the repository at this point in the history
* improve: move xr init to infrastructure

* fix: move initxr, before gfx

* fix: format warning
  • Loading branch information
fqamic committed Sep 14, 2022
1 parent f465073 commit f838e06
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cocos/core/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,17 +686,6 @@ export class Game extends EventTarget {
if (DEBUG) {
console.timeEnd('Init Base');
}

if (sys.isXR) {
// XrEntry must not be destroyed
xr.entry = xr.XrEntry.getInstance();

const xrMSAA = settings.querySettings(Settings.Category.RENDERING, 'msaa') ?? 1;
const xrRenderingScale = settings.querySettings(Settings.Category.RENDERING, 'renderingScale') ?? 1.0;
xr.entry.setMultisamplesRTT(xrMSAA);
xr.entry.setRenderingScale(xrRenderingScale);
}

this.emit(Game.EVENT_POST_BASE_INIT);
return this.onPostBaseInitDelegate.dispatch();
})
Expand All @@ -711,6 +700,7 @@ export class Game extends EventTarget {
console.time('Init Infrastructure');
}
macro.init();
this._initXR();
const adapter = findCanvas();
if (adapter) {
this.canvas = adapter.canvas;
Expand Down Expand Up @@ -805,6 +795,18 @@ export class Game extends EventTarget {
});
}

private _initXR () {
if (sys.isXR) {
// XrEntry must not be destroyed
xr.entry = xr.XrEntry.getInstance();

const xrMSAA = settings.querySettings(Settings.Category.RENDERING, 'msaa') ?? 1;
const xrRenderingScale = settings.querySettings(Settings.Category.RENDERING, 'renderingScale') ?? 1.0;
xr.entry.setMultisamplesRTT(xrMSAA);
xr.entry.setRenderingScale(xrRenderingScale);
}
}

private _compatibleWithOldParams (config: IGameConfig) {
const overrideSettings = config.overrideSettings = config.overrideSettings || {};
if ('showFPS' in config) {
Expand Down

0 comments on commit f838e06

Please sign in to comment.