Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/framework/xr/xr-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ class XrManager extends EventHandler {
this._available[XRTYPE_VR] = false;
this._available[XRTYPE_AR] = false;

this.views = new XrViews(this);
this.domOverlay = new XrDomOverlay(this);
this.hitTest = new XrHitTest(this);
this.imageTracking = new XrImageTracking(this);
Expand Down Expand Up @@ -570,8 +569,7 @@ class XrManager extends EventHandler {
* end.
*
* @param {XrErrorCallback} [callback] - Optional callback function called once session is
* started. The callback has one argument Error - it is null if successfully started XR
* session.
* ended. The callback has one argument Error - it is null if successfully ended XR session.
* @example
* app.keyboard.on('keydown', (evt) => {
* if (evt.key === pc.KEY_ESCAPE && app.xr.active) {
Expand Down Expand Up @@ -716,6 +714,10 @@ class XrManager extends EventHandler {
this._setClipPlanes(this._camera.nearClip, this._camera.farClip);
};

const onFrameRateChange = () => {
this.fire('frameratechange', this._session?.frameRate);
};

// clean up once session is ended
const onEnd = () => {
if (this._camera) {
Expand All @@ -727,6 +729,7 @@ class XrManager extends EventHandler {

session.removeEventListener('end', onEnd);
session.removeEventListener('visibilitychange', onVisibilityChange);
session.removeEventListener('frameratechange', onFrameRateChange);

if (!failed) this.fire('end');

Expand Down Expand Up @@ -763,9 +766,7 @@ class XrManager extends EventHandler {
this._supportedFrameRates = null;
}

this._session.addEventListener('frameratechange', () => {
this.fire('frameratechange', this._session?.frameRate);
});
this._session.addEventListener('frameratechange', onFrameRateChange);

// request reference space
session.requestReferenceSpace(spaceType).then((referenceSpace) => {
Expand Down
Loading