krpano

krpano: custom plugin action not known / registered?


I try to test a very basic custom plugin action, but I seem to have made a mistake.

This is my plugin:

function krpanoplugin() {
    var local = this;   // save the 'this' pointer from the current plugin object

    var krpano = null;  // the krpano and plugin interface objects
    var plugin = null;

    var xml_value = 100.0;   // the value for a custom xml attribute

    // registerplugin - startup point for the plugin (required)
    // - krpanointerface = krpano interface object
    // - pluginpath = the fully qualified plugin name (e.g. "plugin[name]")
    // - pluginobject = the xml plugin object itself
    local.registerplugin = function(krpanointerface, pluginpath, pluginobject) {
        // get the krpano interface and the plugin object
        krpano = krpanointerface;
        plugin = pluginobject;

        // first - say hello
        krpano.trace(1, "Bridge Plugin loaded: [" + plugin.name + "]");

        // add plugin action (the attribute needs to be lowercase!)
        plugin.jsbmodal = action_jsbmodal;
    };

    function action_jsbmodal() {

        console.log(arguments);
        krpano.trace(arguments);
    }
}

But if I try to execute the action onClick at a hotspot like this:

<hotspot  name="hotspot_171" style="link_hs_sm"  url="%CURRENTXML%/add_hotspot/picture/icon-text.png" distorted="true" alpha="1" capture="true" depth="1000" flying="0" handcursor="true" zorder="5" zoom="false"
            ath="160.8416" atv="-37.4461" width="50" height="prop" rx="0" ry="0" rz="0" ox="0" oy="0" rotate="0" scale="1" edge="center"
            install_onclick="3" name_hs="hotspot_171" scene_EL="scene_8" info_Ah="add_hotspot/text/leipzig-test.html" fov_EL="140" enabled2="true" visible2="true" drag_hs="true"
            onclick="jsbmodal('om')"
        />

I only get the following message:

 WARNING: Unknown action: jsbmodal

I have registered the plugin like this:

<plugin name="jsbModal" url="../jsbModalPlugin.js" keep="true" preload="true" />

Can you see where I made the mistake?


Solution

  • According to https://krpano.com/forum/wbb/index.php?page=Thread&postID=78841 the probably cleanest solution is to use the plugin action syntax in the xml:

    plugin[YOUR_PLUGIN_NAME].yourAction()

    Which is in my case:

    <hotspot name="hotspot_171" [...]
             onclick="plugin[jsbmodal].jsbmodal('om')"
    />