-
Notifications
You must be signed in to change notification settings - Fork 2
/
krpano_orientation.js
59 lines (47 loc) · 1.51 KB
/
krpano_orientation.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* KRPano Orientation V0.1.0
* URL: https://github.com/senegalo/krpano-orientation
* Author: Karim Mansour
*/
function krpanoplugin() {
class KRpanoOrientation {
constructor(krpano, pluginPath, pluginObj) {
this.krpano = krpano;
this.pluginPath = pluginPath;
this.pluginObj = pluginObj;
this.registerEventsCallback();
}
registerEventsCallback() {
var self = this;
this.krpano.set('events.onremovepano', function(){
self.cacheOrientation();
});
this.krpano.set('events.onnewpano', function(){
self.correctOrientation();
})
}
cacheOrientation() {
this.orientation_h = this.getKRpanoFloat('view.hlookat') - this.getKRpanoFloat('view.refhlookat');
this.orientation_v = this.getKRpanoFloat('view.vlookat') - this.getKRpanoFloat('view.refvlookat');
}
correctOrientation() {
var vlookat = this.orientation_v + this.getKRpanoFloat('view.refvlookat');
var hlookat = this.orientation_h + this.getKRpanoFloat('view.refhlookat');
this.krpano.call('skin_lookat('+hlookat+','+vlookat+')');
}
getKRpanoFloat(property) {
return parseFloat(this.krpano.get(property)) || 0;
}
destroy() {
// Goodbye Cruel world !!
}
}
var plugin = null;
this.registerplugin = function(krpanointerface, pluginpath, pluginobject){
plugin = new KRpanoOrientation(krpanointerface, pluginpath, pluginobject);
}
this.unloadplugin = function() {
plugin.destroy;
plugin = null
}
}