Ar.js: Keeping the object on the screen even when the camera is not focusing the marker

Created on 6 Mar 2018  路  13Comments  路  Source: jeromeetienne/AR.js

Is there any way to retain the object after moving the camera away from the marker once scanned? so that the user need not focus his camera continuously?

Most helpful comment

Using the marker camera is more stable than the entity camera if the camera's going to be moving around.

For example, instead of this:

<a-marker preset="hiro"></a-marker>

Try this:

<a-marker-camera preset="hiro"></a-marker-camera>

And remove this:

<a-entity camera></a-entity>

Link to docs

All 13 comments

Using the marker camera is more stable than the entity camera if the camera's going to be moving around.

For example, instead of this:

<a-marker preset="hiro"></a-marker>

Try this:

<a-marker-camera preset="hiro"></a-marker-camera>

And remove this:

<a-entity camera></a-entity>

Link to docs

@chznbaum Thank you, I understand what you are saying. I also wanted to know, say if we remove the camera away from the marker ( not focusing the marker ) after the scan can the model still stay on the screen?

@MrRaam Yes, if you're using the marker camera. The model's position will adjust once the marker's back in view/focus.

@chznbaum Can you have multiple a-marker-camera in the same scene, so that you can have multiple independent markers that all use the camera transform matrix?

Is it possible to move the model to the centre of the screen/camera when it lost focus on the marker?

Using the marker camera is more stable than the entity camera if the camera's going to be moving around.

For example, instead of this:

<a-marker preset="hiro"></a-marker>

Try this:

<a-marker-camera preset="hiro"></a-marker-camera>

And remove this:

<a-entity camera></a-entity>

Link to docs
hello eveybody
I have a question, i want to keep object not onlyon screen but in the same position (old position of marker) sthing like vuforia option? i didnt find anysolotion until now ? does somebody know ? please say

hello everybody
I have a question, I want to keep object not only on screen but in the same position (old position of marker) thing like vuforia option? I didn't find any solution until now? does somebody know? please say

Is it possible to move the model to the centre of the screen/camera when it lost focus on the marker?

Yes, it possible. Manipulate the model using DOM with markerFound and markerLost like this:

<script>
// a-scene
        var scene = document.querySelector("a-scene");

        // a-marker
        var m = document.querySelector("a-marker");

        // Create object bola
        function bola(zaxis) {
            // if bola exist, remove
            if (document.querySelector("a-sphere")) {
                let bol = document.querySelector("a-sphere");
                bol.parentNode.removeChild(bol);
            }
            // template literal to create object, z axis for marker = 0, for scene = -5
            var bola = `<a-sphere position="0 0 ${zaxis}" color="red" radius="0.5"></a-sphere>`;
            return bola;
        }

        m.addEventListener("markerFound", (e) => {
            m.insertAdjacentHTML('beforeend', bola(0));
        });

        m.addEventListener("markerLost", (e) => {
            scene.insertAdjacentHTML('beforeend', bola(-5));
        });
    </script>

You can see the full script here

hello everybody
I have a question, I want to keep object not only on screen but in the same position (old position of marker) thing like vuforia option? I didn't find any solution until now? does somebody know? please say

Manage to do this accidentaly. Only works in Chromium based browser. Here it is:

<a-scene embedded vr-mode-ui="enabled: false" arjs='debugUIEnabled: false;'>

        <a-plane position="0 0 0" rotation="-90 0 0" width="1" height="1" color="blue"></a-plane>

        <a-marker-camera preset="hiro"></a-marker-camera>
    </a-scene>

It seems to be working when the entity was put outside a-marker by using a-marker-camera. You can see the code here

Guess it would be a nice feature to be able to use the device's sensors (gyroscope,magnetometer,accelerometer) to continue the tracking when the marker is lost. If one has to understand the transformation matrix to get this working then maybe someone else will have to give this proposal a shot.

@meizano I copied your script I found here and I tried displaying it on a github web page here, but all I see is a blank screen. Do you know how I should fix this? Thanks!

Yes, 馃憤 +1 on this feature!

When loosing the marker, it makes total sense to have an option to change its children to a global (gyroscope based) position. It's very useful when you have bigger objects or animations that might move away from the marker.

I do believe this would become a MUST, to add so many different effects, demos and tools!

I even looked a little into the code to see if it could be "easy" to implement some basic behavior like that, but had a hard time finding documentation on how to contribute to this (amazing) project!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

soundTricker picture soundTricker  路  5Comments

shigenobu-kondo picture shigenobu-kondo  路  6Comments

kurai021 picture kurai021  路  6Comments

arifqz picture arifqz  路  4Comments

Suresh3d picture Suresh3d  路  7Comments