AR-js-org / AR.js

Image tracking, Location Based AR, Marker tracking. All on the Web.
MIT License
5.41k stars 924 forks source link

Location based AR - Depth and distance problem #203

Open matijafumic opened 3 years ago

matijafumic commented 3 years ago

Hello everyone, I am trying to build a location based AR project and have encountered following issues:

1) I loaded my gltf model on a local castle in my town. The castle is around one kilometer air distance from my house. The problem is that the model loads the moment I open my app. I want the model to be visible only when the user is around 100 meters of the castle(provided longitude/latitude of the model). I tried using the maxDistance attribute on the gps-camera but the model still loads when opening the app. Another feature that I want to implement is that model shows only in front of the castle, not when you are looking at it from the back. Something like a semicircle with center in the given location and radius of 100 meters to the front of the castle. Any ideas on how to implement this?

2) Another problem I found is that the scene doesn't have the feeling of depth. What I see when the model is loaded is just a model sticked on the screen in the direction of the location provided in entity. You test that by putting your hand in front od the camera. When you do it you can still see the model normally in front of my hand like there isn't and interruptions. Also I can see the model through walls. Model should be barely visible behind my hand. Any ideas how to fix this?

Here is the basic example of code I used and screenshot of a problem(once again a reminder that the location is one kilometer from my house)

Code: https://github.com/matijafumic/AR/blob/main/index.html

Example

nickw1 commented 3 years ago

Hi @matijafumic. to set the maximum distance you can adjust the far property of your camera, e.g. if you do <a-camera gps-projected-camera near='0.1' far='100' ...> then only content up to 100m away will be displayed.

The 'hand' problem would be a hard one to solve. The way AR.js (and probably the majority of location-based AR toolkits) works is that the augmented content is always drawn on top of the camera feed, never behind. To get this to work as you describe, we'd have to somehow calculate the real distance of real-world objects (such as your hand) in the camera feed, and then display augmented content either in front of or behind the camera feed depending on this, which would be a diffficult problem to solve.

You can, however, control the maximum distance to draw the content, as described above.

matijafumic commented 3 years ago

Thank you very much for your help! I get what you are saying yeah. I'll try to do some research and if I manage to find something out, I'll post here. However, do you think it would be possible to get that depth that I want using AR in unity engine?

bere3 commented 3 years ago

@nickw1 @matijafumic been experiencing a similar problem like Matija. I just can't get that sense of depth on a position of a model placed in the scene. If I place it on a location that's 50 meters away from me when I look it through my phone it looks like the model is 2 meters away from me. Is there any solution for that problem?

nickw1 commented 3 years ago

@bere3 is this because you need to scale the model down to a more realistic size? If you move away from the model location, does it get smaller?