Enter WebVR mode with via external Javascript function

  • I'm programming 360 Tours with an custom overlay.
    What I do is I call JS functions to load the scenes by JavaScript and that works great.

    Code
    krpano.call("loadscene(scene_IMG_0013_Panorama_(1), null, MERGE, BLEND(1)););");

    Now with this new WebVR function I want to enter the WebVR mode (and exit) via an DIV button.

    But I have a problem with loading the WebVR and get 'webvr is not defined' when I want to call the 'webvr' instance.

    I know that I can only call this instance when it's loaded and ready, but what I try I won't be able to
    get it working. I tried it in the Document Ready or in de plugin attributes 'onavailable'. Nothing is working.

    My question. Can I build a 'startWebVR()' function and call this by click on the DIV?

  • My question. Can I build a 'startWebVR()' function and call this by click on the DIV?


    Yes you can.

    Assuming the <div> element is implemented on the same level where you load the KRpano, you can simply use :

    Code
    onclick='krpano().call("webvr.enterVR();");'

    and this will get you into vrmode by pressing a HTML element.

    You could also put this in a javascript function and alternatively you can make a KRpano action that does the same thing, depending on your needs (if you need to set variables or something).

  • Thanks for your reply. Sounds good, and I tried it right away...but I get an error.

    Code
    krpano is not a function

    I tried also:

    Code
    krpano.call("webvr.enterVR();");

    also an error.

    I have an function to toggle the GYRO and that is working like this:

    There I can use krpano.set...is this not possible with 'enterVR'?

  • Found a solution!

    In the plugin setting there are two attributes:

    Code
    plugin name="WebVR" keep="true" devices="html5"
    	    	pluginurl="%SWFPATH%/plugins/webvr.js"
    	    	url=""

    I don't know why but the pluginurl is not working and loading the JS file, so I copied the link to URL attribute
    and now the JS file is loaded..

    Then I use this function now to toggle to EnterVR

    Code
    function enterVR() {
    	var krpano = document.getElementById('krpanoSWFObject');
    	krpano.call("webvr.enterVR()");
    }

    and that is working...

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!