Call functions that live in three.krpanoplugin.js

  • Hi all

    How do I call functions that live in three.krpanoplugin.js from my xml file. For instance when a hotspot is clicked I need to modify a 3d model material but I having hard time targeting functions that live in three.krpanoplugin.js.



    My xml:

    Code
    <action name='hotspot_clicked'>	plugin[threejs].changeTexture() /// was hoping something like this works</action>


    three.krpanoplugin.js

    Code
    function changeTexture(){	console.log('changeTexture called');}
  • Still having issues here with calling plugin functions. I believe I have it set up properly but it's still generating an error WARNING: unknown action: plugin[threejs].changeTexture

    Any suggestions?


    EDIT: This works, minor mistake. But I did notice that the plugin functions are not available on onstart. Anyhow I'm happy I got this resolved.

    in my xml

    Code
    <action name='hotspot_clicked'>	plugin[threejs].changeTexture();</action>


    In three.krpano.js plugin

    Code
    local.registerplugin = function(krpanointerface, pluginpath, pluginobject){	//.......	//.....	plugin.changeTexture = changeTexture;
    }
    function changeTexture(){	console.log( 'changeTexture called');}

    Edited once, last by ecsancho (March 16, 2016 at 6:58 PM).

  • Hi,

    the name of the function at the plugin object need to be 'lowercase'!
    Otherwise it wouldn't be callable by xml actions code.

    Thats because all variable and function names that will be used in the xml will be internally converted to lower-case to be callable regardless of the case.

    That means instead of:
    plugin.changeTexture = changeTexture

    this would need to be used:
    plugin.changetexture = changeTexture

    The case in the xml itself doesn't matter.

    Best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!