Skip to content

Commit 082da25

Browse files
committed
Fix button not showing 'Exit VR' when a session starts
1 parent ab8b4a4 commit 082da25

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

layers-samples/proj-layer.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
function onSessionStarted(session) {
134134
xrSession = session;
135135

136+
// This informs the 'Enter XR' button that the session has started and
137+
// that it should display 'Exit XR' instead.
138+
xrButton.setSession(session);
139+
136140
// Render correct controller models if supported by WebXR input profile
137141
scene.inputRenderer.useProfileControllerMeshes(session);
138142

@@ -162,9 +166,7 @@
162166
}
163167

164168
function onSessionEnded(event) {
165-
if (event.session.isImmersive) {
166-
xrButton.setSession(null);
167-
}
169+
xrButton.setSession(null);
168170
xrSession = null;
169171

170172
// In this simple case discard the WebGL context too, since we're not
@@ -193,7 +195,7 @@
193195
if (usingTextureArray) {
194196
gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, glLayer.colorTexture, 0, glLayer.imageIndex);
195197
gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, glLayer.depthStencilTexture, 0, glLayer.imageIndex);
196-
198+
197199
// No need to set the scissor when clearing a layered texture, since only one layer is exposed at a time.
198200
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
199201

0 commit comments

Comments
 (0)