krpano:自定义插件操作未知/已注册?

时间:2019-06-28 03:10:15

标签: krpano

我尝试测试一个非常基本的自定义插件操作,但是我似乎犯了一个错误。

这是我的插件:

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);
    }
}

但是,如果我尝试在这样的热点执行操作onClick

<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')"
        />

我只收到以下消息:

 WARNING: Unknown action: jsbmodal

我已经这样注册了插件:

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

可以看到我在哪里弄错了吗?

1 个答案:

答案 0 :(得分:0)

根据https://krpano.com/forum/wbb/index.php?page=Thread&postID=78841,可能最干净的解决方案是在xml中使用插件操作语法:

plugin[YOUR_PLUGIN_NAME].yourAction()

在我的情况下:

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