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

In location based AR, I am not able to walk around the 3-D model. #566

Open vizsatiz opened 1 year ago

vizsatiz commented 1 year ago

Do you want to request a feature or report a bug? Report a bug

What is the current behavior? When I create and run the AR.js app for goe-location-based AR model rendering, the model rendered stays there, and when I move towards it, it moves back. By this I mean, am not able to move around the model as the model keeps facing me. Is this expected ? I am trying out in Bangalore, India.

If the current behavior is a bug, please provide the steps to reproduce.

Please mention other relevant information such as the browser version, Operating System and Device Name Tested this in chrome & safari on phone

What is the expected behavior? I should be able to move around the model

If this is a feature request, what is motivation or use case for changing the behavior? Not a feature

Code:

<script lang="ts">
    let testEntityAdded = false;

    window.onload = () => {
        const el = document.querySelector("[gps-new-camera]");

        el.addEventListener("gps-camera-update-position", (e: any) => {
            if(!testEntityAdded) {
                alert(`Got first GPS position: lon ${e.detail.position.longitude} lat ${e.detail.position.latitude}`);
                // Add a box to the north of the initial GPS position
                const entity = document.createElement("a-entity");
                entity.setAttribute("scale", {
                    x: 10, 
                    y: 10,
                    z: 10
                });
                entity.setAttribute('animation', "property: rotation; to: 0 360 0; easing: linear; loop: true; dur: 10000" );
                entity.setAttribute('gltf-model', './assets/models/pokemon/movie_camera.glb' );
                entity.setAttribute('gps-new-entity-place', {
                    latitude: e.detail.position.latitude + 0.0005,
                    longitude: e.detail.position.longitude
                });
                document.querySelector("a-scene").appendChild(entity);
            }
            testEntityAdded = true;
        });
}
</script>

<a-scene vr-mode-ui='enabled: false' arjs='sourceType: webcam; videoTexture: true; debugUIEnabled: false' renderer='antialias: true; alpha: true'>
    <a-camera gps-new-camera='gpsMinDistance: 2'></a-camera>
</a-scene>

Libraries Used:

<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
 <script type='text/javascript' src='https://raw.githack.com/AR-js-org/AR.js/master/three.js/build/ar-threex-location-only.js'></script>
 <script type='text/javascript' src='https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js'></script>
Platform-Group commented 1 year ago

0.0001 degrees to the north is about 11 meters, so not much, if I had to guess it's simply because your GPS isn't updating your position because you're not walking very far? The cameras position can only be updated as the GPS is updated, if your GPS is relatively inaccurate then it's not going to pick up changes of only 11m. I know my current AR.js project is in a skyscraper so GPS is practically useless thanks to the interference and I had to put in a system for changing simulated coordinates.

Platform-Group commented 1 year ago

I forgot to mention, you can always put some logs into your gps-camera-update-position to see when it's firing and how accurate it is. Here's a function for measuring the distance in meters between two sets of coordinates, it may help you in debugging.

  function measure(lat1, lon1, lat2, lon2) {
    // generally used geo measurement function
    var R = 6378.137; // Radius of earth in KM
    var dLat = (lat2 * Math.PI) / 180 - (lat1 * Math.PI) / 180;
    var dLon = (lon2 * Math.PI) / 180 - (lon1 * Math.PI) / 180;
    var a =
      Math.sin(dLat / 2) * Math.sin(dLat / 2) +
      Math.cos((lat1 * Math.PI) / 180) *
        Math.cos((lat2 * Math.PI) / 180) *
        Math.sin(dLon / 2) *
        Math.sin(dLon / 2);
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    var d = R * c;
    return d * 1000; // meters
  }
mamoone commented 9 months ago

any good news ?!

vizsatiz commented 9 months ago

0.0001 degrees to the north is about 11 meters, so not much, if I had to guess it's simply because your GPS isn't updating your position because you're not walking very far? The cameras position can only be updated as the GPS is updated, if your GPS is relatively inaccurate then it's not going to pick up changes of only 11m. I know my current AR.js project is in a skyscraper so GPS is practically useless thanks to the interference and I had to put in a system for changing simulated coordinates.

I really dont think this is the issue as I tried changing those values

vizsatiz commented 9 months ago

any good news ?!

All I could understand was there were some issues with Southern hemisphere, for more info https://github.com/AR-js-org/AR.js/issues/278

nickw1 commented 9 months ago

I don't think this is anything to do with the Southern Hemisphere, but possibly inherent limitations in the sensors of specific devices and/or iOS-related bugs. Perhaps related to #547 #552 #590? We haven't yet identified a definite cause as the occurrence is rather random, which suggests it's a device-specific issue.

GPS only has a certain accuracy though, being able to "walk around" a model on GPS alone is unlikely to work as GPS isn't that accurate.

marcusx2 commented 8 months ago

It's normal, you can't walk around a model.