Hi. I want to know if it is possible to get the xr controller movement. As example, if it is getting closer to an object or not, or the distance between this object and controller. Any sugestions are welcome
Thanks!
Ping @RaananW
hi,
you could track and calculate the deltas on each frame, just like you would with any moving object. There is no magic other than that
Thanks @RaananW.
I tried something https://playground.babylonjs.com/#IJ59F0#3
Something like this?
Sure! if it fits your usecase, why not
I would personally use DistanceSquared, especially if you can calculate a squared distance from the object. It saves one Math.sqrt
call each frame, which will increase performance a bit.
Great, thanks.
Iβm trying to make a difference between click and drag on an object, without succes till now, but keep trying
Why donβt you use the pointer system? pointerdown + pointermove will give you drag, pointerdown + pointerup will give you a click
This is a good idea, but how I know from scene pointer which controller clicked or dragged the object? (because on drag I want to parent the draggable object to the controller.
Sorry for bothering you
You are not bothering at all!
Every pointer event has a pointerId, which is a number (kind of like an index) - located at pointerInfo.event.pointerId
. You can get the controller corresponding to this ID using getXRControllerByPointerId
in the xr pointer feature. You can also write your own logic using this number. The number will stay the same as long as the controller is still detected, so you can use it to compare between events.
I got it to woooork
Thank you
Makes me very happy to read