Skip to content

Commit d8231ea

Browse files
authored
Merge pull request #223 from cabanier/control-depth
add test to pause/resume depth
2 parents bc8170a + e01a879 commit d8231ea

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

js/render/core/renderer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ uniform sampler2DArray depthColor;
123123
uniform float rawValueToMeters;
124124
out vec4 color;
125125
in vec4 vWorldPosition;
126+
uniform bool sortDepth;
127+
126128
uniform mat4 LEFT_DEPTH_PROJECTION_MATRIX, LEFT_DEPTH_VIEW_MATRIX, RIGHT_DEPTH_PROJECTION_MATRIX, RIGHT_DEPTH_VIEW_MATRIX;
127129
128130
float Depth_GetCameraDepthInMillimeters(const sampler2DArray depthTexture,
@@ -205,6 +207,10 @@ void main() {
205207
return;
206208
}
207209
210+
if (!sortDepth) {
211+
return;
212+
}
213+
208214
float assetDepthMm = gl_FragCoord.z * 1000.0 * rawValueToMeters;
209215
210216
float occlusion = Depth_GetBlurredOcclusionAroundUV(depthColor, depthPositionHC, assetDepthMm);
@@ -962,6 +968,9 @@ export class Renderer {
962968
gl.uniform1ui(program.uniform.VIEW_ID, i);
963969
}
964970
}
971+
if (depthData) {
972+
gl.uniform1i(program.uniform.sortDepth, depthData.length > 0);
973+
}
965974
if ((i == 0) && depthData && depthData.length) {
966975
// for older browser that don't support projectionMatrix and transform on the depth data
967976
gl.uniformMatrix4fv(program.uniform.LEFT_DEPTH_PROJECTION_MATRIX, false, views[0].projectionMatrix);

layers-samples/proj-multiview-occlusion.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,17 @@
162162
+ event.session.visibilityState);
163163
}
164164

165+
function onSelectStart(ev) {
166+
let session = ev.frame.session;
167+
session.depthActive ? session.pauseDepthSensing() : session.resumeDepthSensing();
168+
}
169+
165170
function onSessionStarted(session) {
166171
session.addEventListener('end', onSessionEnded);
167172
session.addEventListener('visibilitychange', onVisibilityChange);
168173

174+
session.addEventListener('selectstart', onSelectStart);
175+
169176
initGL();
170177

171178
if (session.isImmersive) {

0 commit comments

Comments
 (0)