Hi there!
I´m working on a plugin that will need a middle mouse button pan on flat panoramas. In this
interactive sandobox (fork to edit) you can play the code in real time.
I need help with the
pan function. I know how to drag layers, hotspots, etc, but still didn't realize how to implement the drag to change the vlookat and hlookat values.
The code in the sandbox is as follows:
|
XML
|
1
2
3
4
5
|
<krpano onstart="set(debugmode, get(editmode));" >
<plugin name='mousecontrol' url='mouse.js' />
<view hlookat="0.0" vlookat="0.0" fovtype="VFOV" fov="0.5625" fovmax="0.5625" maxpixelzoom="1.0" limitview="fullrange" />
<image hfov="1.00" vfov="0.562500" voffset="0.00"> <flat url="01.jpg"/> </image>
</krpano>
|
|
Javascript-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
var krpanoplugin = function () {
var local = this;
var krpano = null;
var plugin = null;
var device = null;
var browserevents = null;
local.registerplugin = function (krpanointerface, pluginpath, pluginobject) {
krpano = krpanointerface;
plugin = pluginobject;
device = krpano.device;
browserevents = device.browser.events;
/* MOUSE EVENTS ******/
// krpano.control.usercontrol = "off";
if (browserevents.mouse) {
krpano.control.layer.addEventListener("mousedown", onMouseDown);
} };
local.unloadplugin = function () {
plugin = null;
krpano = null;
};
/* **** FUNCTIONS ******/
function onMouseDown(ev) {
if (ev.buttons === 4) {
console.log("middle mouse button DOWN");
if (browserevents.mouse) {
window.addEventListener("mousemove", pan);
window.addEventListener("mouseup", onMouseUp);
}
}
}
function pan(ev) {
console.log(`x: ${ev.x}, y: ${ev.y}`);
}
function onMouseUp(ev) {
console.log("middle mouse button UP");
if (browserevents.mouse) {
window.removeEventListener("mousemove", pan);
window.removeEventListener("mouseup", onMouseUp);
}
}
};
|
Any help?