Skip to content

Commit

Permalink
fix(example): auto init room capture if no plane is detected
Browse files Browse the repository at this point in the history
Summary: #2

Reviewed By: cabanier

Differential Revision:
D51274594

Privacy Context Container: L1179008

fbshipit-source-id: 8b98a00c9456abfd309cc853bb807ec9885f772c
  • Loading branch information
felixtrz authored and facebook-github-bot committed Nov 13, 2023
1 parent f150f94 commit 53aabdd
Show file tree
Hide file tree
Showing 5 changed files with 746 additions and 13 deletions.
23 changes: 23 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
import { ARButton, RealityAccelerator } from 'ratk';
import {
BoxGeometry,
BufferGeometry,
DirectionalLight,
HemisphereLight,
Line,
Mesh,
MeshBasicMaterial,
PerspectiveCamera,
Scene,
SphereGeometry,
Vector3,
WebGLRenderer,
} from 'three';

Expand Down Expand Up @@ -126,6 +130,13 @@ function setupController() {
controllerModelFactory.createControllerModel(controllerGrip),
);
scene.add(controllerGrip);

const geometry = new BufferGeometry().setFromPoints([
new Vector3(0, 0, 0),
new Vector3(0, 0, -1),
]);
const line = new Line(geometry);
renderer.xr.getController(0).add(line);
}

/**
Expand All @@ -136,6 +147,13 @@ function handleControllerConnected(event) {
.createHitTestTargetFromControllerSpace(event.data.handedness)
.then((hitTestTarget) => {
this.hitTestTarget = hitTestTarget;
const geometry = new SphereGeometry(0.05);
const material = new MeshBasicMaterial({
transparent: true,
opacity: 0.5,
});
const hitTestMarker = new Mesh(geometry, material);
this.hitTestTarget.add(hitTestMarker);
});
}

Expand Down Expand Up @@ -185,6 +203,11 @@ function setupRATK() {
});
});
}, 1000);
setTimeout(() => {
if (ratk.planes.size == 0) {
renderer.xr.getSession().initiateRoomCapture();
}
}, 5000);
});
}

Expand Down
63 changes: 52 additions & 11 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"serve": "webpack serve"
},
"dependencies": {
"ratk": "file:../ratk-build.tgz",
"ratk": "file:../",
"three": "npm:[email protected]",
"troika-three-text": "0.49.0"
}
Expand Down
Loading

0 comments on commit 53aabdd

Please sign in to comment.