jeromeetienne / AR.js

Efficient Augmented Reality for the Web - 60fps on mobile!
MIT License
15.79k stars 2.22k forks source link

A-Frame AR change webcam viewport size (when i tried to change heigth and width, goes back) #750

Closed Invius closed 4 years ago

Invius commented 4 years ago

I used jquery to try and size the video component that it generated from the a-scene, and it changes the value from the component, but i think that ar.js is triggering on resize event to ajust back to the window size. I've tried to change the arjs attribute but nothing happens. Is there a way to set a fixed size, instead of having it full screen/window sized? Or is this a bug from the framework?

I have reported this also to: a-frame And redirected to this git:

This is a question more appropriate for the arjs maintainers

let videoComponent = $("video");
videoComponent.height(300);
videoComponent.width(300);

<a-scene embedded arjs='sourceType: webcam; sourceWidth: 600; sourceHeight: 400; displayWidth: 600; displayHeight: 400; canvasWidth: 600; canvasHeight: 400; debugUIEnabled: false;' >

nicolocarpignoli commented 4 years ago

It is an open bug. On the file system-arjs.js


        //////////////////////////////////////////////////////////////////////////////
        //      Code Separator
        //////////////////////////////////////////////////////////////////////////////
        // TODO this is crappy - code an exponential backoff - max 1 seconds
        // KLUDGE: kludge to write a 'resize' event
        var startedAt = Date.now()
        var timerId = setInterval(function () {
            if (Date.now() - startedAt > 10000 * 1000) {
                clearInterval(timerId)
                return
            }
            // onResize()
            window.dispatchEvent(new Event('resize'));
        }, 1000 / 30)

This snippet is a bad trick that triggers a resize event multiple times per seconds. It has to be removed. I tried long time ago to do that, listening to the browser 'resize' event but it is not enough, for some reason.

nicolocarpignoli commented 4 years ago

related: https://github.com/jeromeetienne/AR.js/issues/678

nicolocarpignoli commented 4 years ago

moved this issue in new AR.js repository: https://github.com/AR-js-org/AR.js/