Skip to content

Commit

Permalink
add support for room capture
Browse files Browse the repository at this point in the history
  • Loading branch information
cabanier committed Oct 27, 2022
1 parent 223254f commit 8683ae0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Binary file added media/gltf/.DS_Store
Binary file not shown.
23 changes: 22 additions & 1 deletion proposals/plane-detection.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
including implementation of synchronous hit test in JavaScript
leveraging obtained plane data and anchors API to position objects.
<p>
<input id="usePlaneOrigin" type="checkbox">
<input id="usePlaneOrigin" type="checkbox" checked>
<label for="usePlaneOrigin">Plane coordinate system visible</label><br/>

<input id="useDomOverlay" type="checkbox">
<label for="useDomOverlay">Enable DOM Overlay</label><br/>

<input id="useRoomCapture" type="checkbox" checked>
<label for="useRoomCapture">Start room capture if no planes are known</label><br/>

<a class="back" href="./index.html">Back</a>
</p>
</details>
Expand Down Expand Up @@ -69,6 +72,8 @@
let camera, scene, renderer;
let controller1, controller2;
let controllerGrip1, controllerGrip2;
let startTime;
let launchedCapture = false;

const intersected = [];
const tempMatrix = new THREE.Matrix4();
Expand Down Expand Up @@ -217,15 +222,24 @@
});
}

function onVisibilityChange(event) {
console.log("Visibility change for "
+ (event.session.isImmersive ? "immersive" : "non-immersive")
+ " session: "
+ event.session.visibilityState);
}

function onSessionStarted(session) {
useDomOverlay.disabled = true;
session.addEventListener('end', onSessionEnded);
session.addEventListener('select', onSelect);
session.addEventListener('visibilitychange', onVisibilityChange);

renderer.xr.setReferenceSpaceType('local');
renderer.xr.setSession(session);

renderer.setAnimationLoop(render);
startTime = new Date();
}

function onEndSession(session) {
Expand Down Expand Up @@ -535,6 +549,13 @@
}

function render(timestamp, frame) {

if ((frame.detectedPlanes.size === 0) && useRoomCapture.checked && ((new Date() - startTime) > 1000) && (launchedCapture === false)) {
if (frame.session.initiateRoomCapture) {
frame.session.initiateRoomCapture();
}
launchedCapture = true;
}
if (frame) {
cached_frame = frame;
processAnchors(timestamp, frame);
Expand Down

0 comments on commit 8683ae0

Please sign in to comment.