Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebXR - Fixed bug where the wrong number of views is being added #5063

Merged
merged 3 commits into from
Feb 10, 2023
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
46 changes: 21 additions & 25 deletions src/framework/xr/xr-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,32 +694,28 @@ class XrManager extends EventHandler {
const lengthOld = this.views.length;
const lengthNew = pose.views.length;

if (lengthNew > this.views.length) {
// add new views into list
for (let i = 0; i <= (lengthNew - this.views.length); i++) {
let view = this.viewsPool.pop();
if (!view) {
view = {
viewport: new Vec4(),
projMat: new Mat4(),
viewMat: new Mat4(),
viewOffMat: new Mat4(),
viewInvMat: new Mat4(),
viewInvOffMat: new Mat4(),
projViewOffMat: new Mat4(),
viewMat3: new Mat3(),
position: new Float32Array(3),
rotation: new Quat()
};
}

this.views.push(view);
}
} else if (lengthNew <= this.views.length) {
// remove views from list into pool
for (let i = 0; i < (this.views.length - lengthNew); i++) {
this.viewsPool.push(this.views.pop());
while (lengthNew > this.views.length) {
let view = this.viewsPool.pop();
if (!view) {
view = {
viewport: new Vec4(),
projMat: new Mat4(),
viewMat: new Mat4(),
viewOffMat: new Mat4(),
viewInvMat: new Mat4(),
viewInvOffMat: new Mat4(),
projViewOffMat: new Mat4(),
viewMat3: new Mat3(),
position: new Float32Array(3),
rotation: new Quat()
};
}

this.views.push(view);
}
// remove views from list into pool
while (lengthNew < this.views.length) {
this.viewsPool.push(this.views.pop());
}

// reset position
Expand Down