immersive-web / anchors

https://immersive-web.github.io/anchors/
Other
50 stars 20 forks source link

Can a model freely move in AR space? #73

Open Simon1059770342 opened 2 years ago

Simon1059770342 commented 2 years ago
  1. Can a model freely move in AR space?
  2. Is it possible to control virtual model moving in the AR space by just changing the the pose of its anchor originally attached to the model?
  3. If moving virtual model is out of frames for a while, can we re-gain the model as we come close to it or the model come close to us? THX for your help!
AdaRoseCannon commented 2 years ago

You render whatever you want so no reason a model can't move freely. You could always create a new anchor at the destination location and tween between them.

On Fri, 8 Apr 2022, 09:13 Simon1059770342, @.***> wrote:

  1. Can a model freely move in AR space?
  2. Is it possible to control virtual model moving in the AR space by just changing the the pose of its anchor originally attached to the model?
  3. If moving virtual model is out of frames for a while, can we re-gain the model as we come close to it or the model come close to us? THX for your help!

— Reply to this email directly, view it on GitHub https://github.com/immersive-web/anchors/issues/73, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAHSMRHKQYGPNWIMNNVXD3VD7TBRANCNFSM5S3YUIAA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Simon1059770342 commented 2 years ago

THX for your help! Do you mean I can get the anchor for my placed model, and change the pose of the anchor whatever I want? If so, an other issue suddenly came out of my mind: Does WebXR have an Animation API for model movement, or I could make that animation by common ways in JS (like using setTimeout to change model pose every other second)

bialpio commented 2 years ago

THX for your help! Do you mean I can get the anchor for my placed model, and change the pose of the anchor whatever I want?

No, anchor pose is going to be updated by the underlying XR system. When you create an anchor, we are giving you a promise that we will try to update its pose so that it remains fixed relative to the real world. You can then introduce another pose that describes object's coordinates relative to the anchor - you fully control this pose so you can set it to whatever you like.

Maybe a useful way to think about this is: AR APIs are there to try and tell you where the underlying XR system thinks things are in the real world, and you can use that information to influence where you render your own models relative to those "landmarks" the XR system knows about.

If so, an other issue suddenly came out of my mind: Does WebXR have an Animation API for model movement, or I could make that animation by common ways in JS (like using setTimeout to change model pose every other second)

No, WebXR does not have an animation API. When you write a WebXR-powered application, you set a callback via XRSession.requestAnimationFrame(). This callback will be called with time as a parameter, which you can use to drive your animations.

Let me know if this helps! There's an example on how to use Anchors API here, with source code here. Chrome also has additional example here, with source available here (it is used for debugging & a bit more complex as it uses hit-test for anchor placement and also can optionally use an experimental plane detection API, so it may be harder to follow what is happening).

Simon1059770342 commented 2 years ago

THX a lot! This helps me a lot! Follow your advice, I expected to try the plane detection of the environment sample, but I fail with error in my console showed in Fig.1. image

So is there any possible way of visualize result of world detection? Example as Fig.2 image

Simon1059770342 commented 2 years ago

Today I found a demo that can almost explain what I need. If you are interested please try demo in WebXR Viewer on IOS device