Hello everyone, maybe someone knows how to call the normal krpano actions in javascript krpano actions.
Here are the normal krpano actions:
Code
<action name="calculatedistance" scope="local" args="x1, y1, x2, y2"> pow(a, calc(x2-x1), 2); pow(b, calc(y2-y1), 2); set(global.distance, calc(sqrt(a+b))); </action>
<action name="gotoclosesthotspot" scope="local"> getclosesthotspot(); calc(closesths, hotspot[get(global.closesthsname)]); tween(view.tx, get(closesths.tx)); tween(view.tz, get(closesths.tz)); </action>
<action name="getclosesthotspot" scope="local"> set(lowestdistance, 100000); set(global.closesthsname, ""); for(set(i,0), i LE hotspot.count, inc(i), calc(hs, hotspot[get(i)]); if (hs.clickablehotspot == true, set (x1, get(hs.tx)); set (y1, get(hs.tz)); set (x2, get(caller.tx)); set (y2, get(caller.tz)); calculatedistance(get(x1), get(y1), get(x2), get(y2)); if(global.distance LT lowestdistance, set(lowestdistance, get(global.distance)); set(global.closesthsname, get(hs.name)); ); ); ); </action>
<action name="mouse_3d_click" scope="local">
getclosesthotspot();
calc(closesths, hotspot[get(global.closesthsname)]);
tour_loadscene(get(closesths.linkedscene), null, MERGE|KEEPVIEW|KEEPMOVING, BLEND(1));
</action>
I want to call action "mouse_3d_click" in the function ondoubleclick() of javascript krpano actions. Here is the action itself:
ActionScript
<action name="mouse_3d_cursor" type="js" autorun="true" if="device.desktop"><![CDATA[
var mouse3d = null;
var normal = null;
var normal_l = 100.0;
var hit = null;
var renderloop_id = null;
krpano.have_mouse_3d_cursor = false;
krpano.actions.add_mouse_3d_cursor = function()
{
krpano.have_mouse_3d_cursor = true;
mouse3d = krpano.addhotspot("mouse3d_cursor","webgl");
mouse3d.type = "text";
mouse3d.width = mouse3d.height = 50;
mouse3d.bgcolor = 0xFFFFFF;
mouse3d.bgalpha = 0.5;
mouse3d.bgroundedge = 25;
mouse3d.css = "font-size:2px;"
mouse3d.textalign = "center";
mouse3d.distorted = true;
mouse3d.depth = 0;
mouse3d.enabled = false;
mouse3d.oversampling = 3;
normal = krpano.addhotspot("mouse3d_cursor_normal","webgl");
normal.polyline = true;
normal.bordercolor = 0xFFFFFF;
normal.depth = 0;
normal.enabled = false;
renderloop_id = krpano.actions.renderloop( renderloop );
krpano.events.addListener("ondoubleclick", ondoubleclick);
}
krpano.actions.remove_mouse_3d_cursor = function()
{
if (mouse3d)
{
mouse3d.remove();
mouse3d = null;
}
if (normal)
{
normal.remove();
normal = null;
}
if (renderloop_id)
{
krpano.actions.stoprenderloop(renderloop_id);
renderloop_id = null;
}
krpano.events.removeListener("ondoubleclick", ondoubleclick);
krpano.have_mouse_3d_cursor = false;
}
function ondoubleclick() // Enter an action "mouse_3d_click" here :
{
}
function renderloop()
{
if (krpano.hoveringelement)
{
mouse3d.alpha = normal.alpha = 0;
hit = null;
}
else
{
hit = krpano.actions.screentodepth(krpano.mouse.x, krpano.mouse.y);
if(hit)
{
mouse3d.alpha = 1;
mouse3d.rx = hit.rx;
mouse3d.ry = hit.ry;
mouse3d.rz = hit.rz;
mouse3d.tx = hit.x;
mouse3d.ty = hit.y;
mouse3d.tz = hit.z;
mouse3d.rotationorder = "zxy";
normal.alpha = 1;
normal.points3d = [hit.x, hit.y, hit.z, hit.x + normal_l*hit.nx, hit.y + normal_l*hit.ny, hit.z + normal_l*hit.nz].join(",");
}
else
{
mouse3d.alpha = 0;
}
}
}
]]></action>
Display More