AdaRoseCannon / aframe-xr-boilerplate

Get started quickly with VR and AR using AFrame
https://aframe-xr-starterkit.glitch.me/
MIT License
110 stars 20 forks source link

Auto-place on ar surface #17

Open Mrbside opened 1 year ago

Mrbside commented 1 year ago

What would I have to do in order to make the arcursor place my arobject automatically like on modelviewer (webxr)? so theres no need to tap on the screen.

I tried to do the following in my script:

  1. Detect when the raycast is hittesting

this.addEventListener( "ar-hit-test-achieved", function() { }, { once: true } );

  1. try to trigger "onselect" method in arcursor

      sceneEl.components.arcursor.onselect();

Problem: I see onselect method in arcursor asks for a parameter "e" which contains frame and inputSource

onselect(e) { const frame = e.frame; const inputSource = e.inputSource; const referenceSpace = this.el.renderer.xr.getReferenceSpace(); const pose = frame.getPose(inputSource.targetRaySpace, referenceSpace); . . .

Is this a good approach or what would be? Could I use the gaze/fuse system in cursor component?

thank you