webarkit / ARnft-threejs

A rendering package for https://github.com/webarkit/ARnft
GNU General Public License v3.0
22 stars 7 forks source link

ARnftThreejs sometimes not start #19

Open kezmanh opened 2 years ago

kezmanh commented 2 years ago

https://github.com/webarkit/ARnft/issues/204

I came from the above thread. I was trying to use my own camera source. So I have the following script

navigator.mediaDevices.enumerateDevices()
.then(gotDevices)
.then(function(){
    navigator.mediaDevices.getUserMedia({
          video: constraints
    })
 .then(function(stream){
      window.stream = stream;
      video.srcObject = stream;

       const entities = [
                  { name: 'game1', markerUrl: "/markers/game1" },
                  { name: 'game2', markerUrl: "/markers/game2" },
                  { name: 'game3', markerUrl: "/markers/game3" },
          ];

      ARnft.ARnft.initWithEntities(640, 480, entities,  '/config.json', true)
      .then((nft) => {
      });

And I commented out navigator.mediaDevices code in ARnft.js. Then, the last console log is ARnftThreejs version: 0.2.0. It seems cannot keep loading the remaining library. Without anymore console log and error log.

    <script src="/js/three.min.js"></script>
    <script src="/js/ARnftThreejs.js"></script>
    <script src="/js/ARnft.js"></script>
    <script src="/js/main.js"></script>

I was using the above structure. ARnft ini function was wrapped inside my custom getUserMedia function in main.js. It causes the ARnftThreejs not keep load. However, there is no problem when I test in desktop and the latest Samsung phone. It has problem only in my old Android phone.

    <script src="/js/three.min.js"></script>
    <script src="/js/ARnftThreejs.js"></script>
    <script src="/js/ARnft.js"></script>
    <script src="/js/main.js"></script>
    <script>
        const entities = [
            { name: 'game1', markerUrl: "/markers/game1" },
            { name: 'game2', markerUrl: "/markers/game2" },
            { name: 'game3', markerUrl: "/markers/game3" },
        ];

        ARnft.ARnft.initWithEntities(640, 480, entities,  '/config.json', true)
        .then((nft) => {})

lastly, when i move the function out. it works again. i am not sure the reason

kalwalt commented 2 years ago

Thank you @kezmanh i will look into it!