You are not logged in.

xinxin

Beginner

  • "xinxin" started this thread

Posts: 13

Location: china

Occupation: software development

  • Send private message

1

Wednesday, September 14th 2016, 7:33pm

krpano.call Unable to create action call

Hello everyone, javascript inside krpano.call action can not be written less than a call to action function, it is that so?
Attach source, I hope you can answer, thank you very much!


function show_addkrpano(){
krpano.call(
"addhotspot(hotspot_line);"+
"set(hotspot[hotspot_line].url,'./comm_line.png');"+
"set(hotspot[hotspot_line].ath,get(view.hlookat));"+
"set(hotspot[hotspot_line].atv,get(view.vlookat));"+
"set(hotspot[hotspot_line].zoom,false);"+
"set(hotspot[hotspot_line].ondown,draghotspot());"+

"<action name='draghotspot'> spheretoscreen(ath, atv, hotspotcenterx, hotspotcentery, 'l');sub(drag_adjustx, mouse.stagex, hotspotcenterx);sub(drag_adjusty, mouse.stagey, hotspotcentery);if(%1 != null,asyncloop(plugin[%1].pressed,sub(dx, mouse.stagex, drag_adjustx);sub(dy, mouse.stagey, drag_adjusty);screentosphere(dx, dy, ath, atv););,asyncloop(pressed,sub(dx, mouse.stagex, drag_adjustx);sub(dy, mouse.stagey, drag_adjusty);screentosphere(dx, dy, ath, atv);););</action>")
}

2

Thursday, September 15th 2016, 9:17am

Hi,

'<action>' is static xml code, that can't be put into an action code call...

Best regards,
Klaus

xinxin

Beginner

  • "xinxin" started this thread

Posts: 13

Location: china

Occupation: software development

  • Send private message

3

Thursday, September 15th 2016, 11:23am

thank you very much! Klaus.
I come inside javascript drag hotspot can be achieved? I wrote a function that should work together, mouse clicks, he would go in the middle of the screen? Help it look? thank you very much!



function show_addkrpano(){
krpano.call("addhotspot(hotspot_line);");
krpano.set("hotspot[hotspot_line].url",'./comm_line.png');
krpano.set("hotspot[hotspot_line].ath",krpano.get("view.hlookat"));
krpano.set("hotspot[hotspot_line].atv",krpano.get("view.vlookat"));
krpano.set("hotspot[hotspot_line].zoom",false);
krpano.set("hotspot[hotspot_line].ondown",draghotspot);
}

function draghotspot(){
var wu = krpano.get("hotspot[hotspot_line].pressed");
var mouse_at_x = krpano.get("mouse.stagex");
var mouse_at_y = krpano.get("mouse.stagey");
var mouse_at_h = krpano.get("view.hlookat");
var mouse_at_v = krpano.get("view.vlookat");
var drag = krpano.spheretoscreen(mouse_at_h,mouse_at_v);
var drag_x = mouse_at_x - drag.x;
var drag_y = mouse_at_y - drag.y;
var dx = mouse_at_x - drag_x;
var dy = mouse_at_y - drag_y;
var screarr = krpano.screentosphere(dx, dy);
//console.log(screarr);
console.log(mouse_at_h);
console.log(mouse_at_v);
var screarr_x = screarr.x;
var screarr_y = screarr.y;
krpano.set("hotspot[hotspot_line].ath",screarr_x);
krpano.set("hotspot[hotspot_line].atv",screarr_y);
}

This post has been edited 1 times, last edit by "xinxin" (Sep 15th 2016, 7:45pm)