A-Frame tap to place

851 views Asked by At

Working with a-frame, can not find a way to create something similar to 8thWall´s Cursor Place Ground. I know a-frame can support markerless AR, but I haven't been able to do it, so if anyone knows of any tutorials or hints on how to do markerless AR that would be great. Thanks.

1

There are 1 answers

2
Piotr Adam Milewski On

You can use the WebXRHitTest API which is encapsulated in the ar-hit-test component.

With a setup like this:

<a-scene ar-hit-test="target:#my-objects;type:footprint;footprintDepth:0.2;">
   <a-entity id="my-objects">
      <a-box></a-box>
   </a-entity>
</a-scene>

You can place the #my-objects entity by tapping on the floor - provided the surface was detected.

To provide some feedback, you can listen on the scene for these events:

  • ar-hit-test-start - when the system has started the scanning process
  • ar-hit-test-achieved - when the surface was found
  • ar-hit-test-select when the user tapped the screen to place an "anchor" with the items.

Resources: