Hi guyss, hope u r doing well
I have another question, if I deploy to glitch and use ar mode, is it possible to track vertical planes to place something like a painting on a wall?
by user 771724594846367796
Hi guyss, hope u r doing well
I have another question, if I deploy to glitch and use ar mode, is it possible to track vertical planes to place something like a painting on a wall?
by user 771724594846367796
Hello, currently WebXR plane detection is not implemented by default so we donโt have support for planes right now. GitHub - immersive-web/real-world-geometry: Additions to WebXR Device API for exposing real world data (Lead: Piotr Bialecki). Plane detection: https://immersive-web.github.io/real-world-geometry/plane-detection.html
But what you can do is get the XRSession and use hit testing to detect โverticalโ surfaces. Have a look at the WebXR.ts
script at line 561 (this is where the AR reticle is updated)
hi @marcel
by user 771724594846367796
Hereโs some code that you need to add it:
first get the hit test source for the viewer
session.requestReferenceSpace('viewer').then((referenceSpace) => {
session.requestHitTestSource({ space: referenceSpace }).then((source) => {
this.hitTestSource = source;
});
});
then you can use that to hit test (the XRFrame is the first argument in onBeforeRender(xrFrame)
const hitTestResults = frame.getHitTestResults(this.hitTestSource);
if (hitTestResults.length) {
const hit = hitTestResults[0];
const referenceSpace = this.webxr.context.renderer.xr.getReferenceSpace();
if (referenceSpace) {
const pose = hit.getPose(referenceSpace);
this.sessionRoot?.onUpdate(this.webxr.Rig, session, pose);
if (this.reticle) {
this.reticle.visible = this.reticleActive;
if (this.reticleActive) {
if (pose) {
const matrix = pose.transform.matrix;
this.reticle.matrix.fromArray(matrix);
if (this.webxr.Rig)
this.reticle.matrix.premultiply(this.webxr.Rig.matrix);
}
}
}
}
}
hope that helps to get you started. And hello @erik_scant
to look at the script you can just click this blue link
ty very much @marcel iโm gonna take a look at it in my free time
by user 771724594846367796