Benutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
: https://pame.virtualtuur.comBenutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
Quoted
sorry, but I don't understand your intention in your example,
Quoted
Try to think this way:
- addListener can be called multiple times and with different functions.
- So to remove the assigned function, it also need to be called with the function that should be removed.
: https://pame.virtualtuur.comDieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Tuur« (12. Oktober 2023, 00:39)
Benutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
: https://pame.virtualtuur.comBenutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
|
|
Source code |
1 2 3 4 |
if(kr == 2){
krpano2.events.removeListener('onviewchanged', sync1);
...
}
|
|
|
Source code |
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
<scene name="scene_1" title="a1" onstart="showlog();" autoload="true">
<preview type="grid(cube,64,64,512,0x666666,0x333333,0x333333);" details="16"/>
<view hlookat="0" limitview="off" fovmax="140" fovmin="70" />
</scene>
<layer name="p2" keep="true" type="krpano" align="lefttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" ondown="DoSync(2)" />
<layer name="p3" keep="true" type="krpano" align="righttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" ondown="DoSync(3)" onloaded="Do();" />
<action name="Do" type="Javascript"><![CDATA[
var krpano2 = krpano.get("layer[p2]").krpano;
var krpano3 = krpano.get("layer[p3]").krpano;
krpano2.image.reset();
krpano2.preview = {
type : "grid(cube,64,64,512,0xffb108,0xff0000,0xffffff)",
details : "16"
};
krpano2.actions.loadpanoimage();
krpano3.image.reset();
krpano3.preview = {
type : "grid(cube,64,64,512,0xffb108,0x4eb74a,0xffffff)",
details : "16"
};
krpano3.actions.loadpanoimage();
]]></action>
<events name="sync" keep="true" ondown="DoSync(1);" />
<action name="DoSync" type="Javascript"><![CDATA[
var v2 = krpano.get("layer[p2]").krpano;
var v3 = krpano.get("layer[p3]").krpano;
var kr = args[1];
function sync1(){
krpano.trace(1, 'sync1');
v3.view.hlookat = v2.view.hlookat = krpano.view.hlookat;
v3.view.vlookat = v2.view.vlookat = krpano.view.vlookat;
v3.view.fov = v2.view.fov = krpano.view.fov;
}
function sync2(){
krpano.trace(1, 'sync2');
krpano.view.hlookat = v3.view.hlookat = v2.view.hlookat;
krpano.view.vlookat = v3.view.vlookat = v2.view.vlookat;
krpano.view.fov = v3.view.fov = v2.view.fov;
}
function sync3(){
krpano.trace(1, 'sync3');
krpano.view.hlookat = v2.view.hlookat = v3.view.hlookat;
krpano.view.vlookat = v2.view.vlookat = v3.view.vlookat;
krpano.view.fov = v2.view.fov = v3.view.fov;
}
if(kr == 1){
krpano.events.addListener('onviewchanged', sync1);
v2.events.removeListener('onviewchanged', sync2);
v3.events.removeListener('onviewchanged', sync3);
}
if(kr == 2){
krpano.events.removeListener('onviewchanged', sync1);
v2.events.addListener('onviewchanged', sync2);
v3.events.removeListener('onviewchanged', sync3);
}
if(kr == 3){
krpano.events.removeListener('onviewchanged', sync1);
v2.events.removeListener('onviewchanged', sync2);
v3.events.addListener('onviewchanged', sync3);
}
]]></action>
|
: https://pame.virtualtuur.com|
|
Source code |
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 60 61 62 63 64 65 |
<scene name="scene_1" title="a1" onstart="showlog();" autoload="true">
<view hlookat="0" limitview="off" fovmax="140" fovmin="70" />
</scene>
<layer name="p1" keep="true" type="krpano" align="lefttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" />
<layer name="p2" keep="true" type="krpano" align="righttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" />
<action name="Do" autorun="onstart" type="Javascript"><![CDATA[
var kr = [
krpano, krpano.get("layer[p1]").krpano, krpano.get("layer[p2]").krpano,
];
kr[0].image.reset();
kr[0].preview = { type : "grid(cube,64,64,512,0x666666,0x333333,0x333333)", details : "16" };
kr[0].actions.loadpanoimage();
kr[1].image.reset();
kr[1].preview = { type : "grid(cube,64,64,512,0xffb108,0xff0000,0xffffff)", details : "16" };
kr[1].actions.loadpanoimage();
kr[2].image.reset();
kr[2].preview = { type : "grid(cube,64,64,512,0xffb108,0x4eb74a,0xffffff)", details : "16" };
kr[2].actions.loadpanoimage();
]]></action>
<events name="sync" keep="true" ondown="DoSync(0);" />
<layer name="p1" ondown="DoSync(1);" />
<layer name="p2" ondown="DoSync(2);" />
<action name="DoSync" type="Javascript"><![CDATA[
var index = args[1];
var kr = [
krpano, krpano.get("layer[p1]").krpano, krpano.get("layer[p2]").krpano,
];
function sync0() {
krpano.trace(1, 'sync 1+2 with 0');
kr[2].view.hlookat = kr[1].view.hlookat = kr[0].view.hlookat;
kr[2].view.vlookat = kr[1].view.vlookat = kr[0].view.vlookat;
kr[2].view.fov = kr[1].view.fov = kr[0].view.fov;
}
function sync1() {
krpano.trace(1, 'sync 0+2 with 1');
kr[0].view.hlookat = kr[2].view.hlookat = kr[1].view.hlookat;
kr[0].view.vlookat = kr[2].view.vlookat = kr[1].view.vlookat;
kr[0].view.fov = kr[2].view.fov = kr[1].view.fov;
}
function sync2() {
krpano.trace(1, 'sync 0+1 with 2');
kr[0].view.hlookat = kr[1].view.hlookat = kr[2].view.hlookat;
kr[0].view.vlookat = kr[1].view.vlookat = kr[2].view.vlookat;
kr[0].view.fov = kr[1].view.fov = kr[2].view.fov;
}
if(index === 0) {
kr[0].events.addListener('onviewchanged', sync0);
kr[1].events.removeListener('onviewchanged', sync1);
kr[2].events.removeListener('onviewchanged', sync2);
}
else if(index === 1) {
kr[0].events.removeListener('onviewchanged', sync0);
kr[1].events.addListener('onviewchanged', sync1);
kr[2].events.removeListener('onviewchanged', sync2);
}
else if(index === 2) {
kr[0].events.removeListener('onviewchanged', sync0);
kr[1].events.removeListener('onviewchanged', sync1);
kr[2].events.addListener('onviewchanged', sync2);
}
]]></action>
|
Benutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
: https://pame.virtualtuur.com|
|
Source code |
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 60 61 62 63 64 65 66 67 68 |
<scene name="scene_1" title="a1" onstart="showlog();" autoload="true">
<view hlookat="0" limitview="off" fovmax="140" fovmin="70" />
</scene>
<layer name="p1" keep="true" type="krpano" align="lefttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" />
<layer name="p2" keep="true" type="krpano" align="righttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" />
<action name="doInit" autorun="onstart" type="Javascript"><![CDATA[
var kr = [
krpano, krpano.get("layer[p1]").krpano, krpano.get("layer[p2]").krpano,
];
kr[0].image.reset();
kr[0].preview = { type : "grid(cube,64,64,512,0x666666,0x333333,0x333333)", details : "16" };
kr[0].actions.loadpanoimage();
kr[0].global_krpano = krpano;
kr[1].image.reset();
kr[1].preview = { type : "grid(cube,64,64,512,0xffb108,0xff0000,0xffffff)", details : "16" };
kr[1].actions.loadpanoimage();
kr[1].global_krpano = krpano;
kr[2].image.reset();
kr[2].preview = { type : "grid(cube,64,64,512,0xffb108,0x4eb74a,0xffffff)", details : "16" };
kr[2].actions.loadpanoimage();
kr[2].global_krpano = krpano;
]]></action>
<events name="sync" keep="true" ondown="doSync(0);" />
<layer name="p1" ondown="doSync(1);" />
<layer name="p2" ondown="doSync(2);" />
<action name="doSync" type="Javascript"><![CDATA[
var index = args[1];
var kr = [
krpano.global_krpano, krpano.get("layer[p1]").krpano, krpano.get("layer[p2]").krpano,
];
function sync0() {
kr[0].trace(1, 'sync 1+2 with 0');
kr[2].view.hlookat = kr[1].view.hlookat = kr[0].view.hlookat;
kr[2].view.vlookat = kr[1].view.vlookat = kr[0].view.vlookat;
kr[2].view.fov = kr[1].view.fov = kr[0].view.fov;
}
function sync1() {
kr[0].trace(1, 'sync 0+2 with 1');
kr[0].view.hlookat = kr[2].view.hlookat = kr[1].view.hlookat;
kr[0].view.vlookat = kr[2].view.vlookat = kr[1].view.vlookat;
kr[0].view.fov = kr[2].view.fov = kr[1].view.fov;
}
function sync2() {
kr[0].trace(1, 'sync 0+1 with 2');
kr[0].view.hlookat = kr[1].view.hlookat = kr[2].view.hlookat;
kr[0].view.vlookat = kr[1].view.vlookat = kr[2].view.vlookat;
kr[0].view.fov = kr[1].view.fov = kr[2].view.fov;
}
if(index === 0) {
kr[0].events.addListener('onviewchanged', sync0);
kr[1].events.removeListener('onviewchanged', sync1);
kr[2].events.removeListener('onviewchanged', sync2);
}
else if(index === 1) {
kr[0].events.removeListener('onviewchanged', sync0);
kr[1].events.addListener('onviewchanged', sync1);
kr[2].events.removeListener('onviewchanged', sync2);
}
else if(index === 2) {
kr[0].events.removeListener('onviewchanged', sync0);
kr[1].events.removeListener('onviewchanged', sync1);
kr[2].events.addListener('onviewchanged', sync2);
}
]]></action>
|
Benutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
help and this seems to be the solution:|
|
Source code |
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
<scene name="scene_1" title="a1" onstart="showlog();" autoload="true">
<preview type="grid(cube,64,64,512,0x666666,0x333333,0x333333);" details="16"/>
<view hlookat="0" limitview="off" fovmax="140" fovmin="70" />
</scene>
<layer name="p2" keep="true" type="krpano" align="lefttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" ondown="DoSync(2)" />
<layer name="p3" keep="true" type="krpano" align="righttop" preload="true" x="0" width="300" height="300" bgcolor="0x000000" bgalpha="1" alpha="1" ondown="DoSync(3)" onloaded="Do();" />
<events name="sync" keep="true" ondown="DoSync(1);" />
<action name="Do" type="Javascript"><![CDATA[
var krpano2 = krpano.get("layer[p2]").krpano;
var krpano3 = krpano.get("layer[p3]").krpano;
krpano2.image.reset();
krpano2.preview = {
type : "grid(cube,64,64,512,0xffb108,0xff0000,0xffffff)",
details : "16"
};
krpano2.actions.loadpanoimage();
krpano3.image.reset();
krpano3.preview = {
type : "grid(cube,64,64,512,0xffb108,0x4eb74a,0xffffff)",
details : "16"
};
krpano3.actions.loadpanoimage();
krpano.tuur = {};
krpano.tuur.sync1 = sync1;
krpano.tuur.sync2 = sync2;
krpano.tuur.sync3 = sync3;
function sync1(){
krpano.trace(1, 'sync1');
krpano3.view.hlookat = krpano2.view.hlookat = krpano.view.hlookat;
krpano3.view.vlookat = krpano2.view.vlookat = krpano.view.vlookat;
krpano3.view.fov = krpano2.view.fov = krpano.view.fov;
}
function sync2(){
krpano.trace(1, 'sync2');
krpano.view.hlookat = krpano3.view.hlookat = krpano2.view.hlookat;
krpano.view.vlookat = krpano3.view.vlookat = krpano2.view.vlookat;
krpano.view.fov = krpano3.view.fov = krpano2.view.fov;
}
function sync3(){
krpano.trace(1, 'sync3');
krpano.view.hlookat = krpano2.view.hlookat = krpano3.view.hlookat;
krpano.view.vlookat = krpano2.view.vlookat = krpano3.view.vlookat;
krpano.view.fov = krpano2.view.fov = krpano3.view.fov;
}
]]></action>
<action name="DoSync" type="Javascript"><![CDATA[
var v2 = krpano.get("layer[p2]").krpano;
var v3 = krpano.get("layer[p3]").krpano;
var kr = args[1];
if (kr != krpano.tuur.active)
{
krpano.tuur.active = kr;
if(kr == 1){
krpano.events.addListener('onviewchanged', krpano.tuur.sync1);
v2.events.removeListener('onviewchanged', krpano.tuur.sync2);
v3.events.removeListener('onviewchanged', krpano.tuur.sync3);
}
if(kr == 2){
krpano.events.removeListener('onviewchanged', krpano.tuur.sync1);
v2.events.addListener('onviewchanged', krpano.tuur.sync2);
v3.events.removeListener('onviewchanged', krpano.tuur.sync3);
}
if(kr == 3){
krpano.events.removeListener('onviewchanged', krpano.tuur.sync1);
v2.events.removeListener('onviewchanged', krpano.tuur.sync2);
v3.events.addListener('onviewchanged', krpano.tuur.sync3);
}
}
]]></action>
|
: https://pame.virtualtuur.com|
|
Source code |
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 |
<action autorun="preinit" type="js"><![CDATA[
krpano.sync_multiple_viewers = function()
{
// convert 'arguments' to an array
var viewers_array = Array.prototype.slice.call(arguments);
// the current/active viewer
var activeviewer = null;
viewers_array.forEach( function(viewer)
{
viewer.events.addListener("ondown", function()
{
activeviewer = viewer;
});
viewer.events.addListener("onviewchanged", function()
{
if(viewer == activeviewer)
{
viewers_array.forEach( function(otherviewer)
{
if (viewer != otherviewer)
{
otherviewer.view.hlookat = activeviewer.view.hlookat;
otherviewer.view.vlookat = activeviewer.view.vlookat;
otherviewer.view.fov = activeviewer.view.fov;
}
});
}
});
});
}
]]></action>
|
|
|
Source code |
1 2 3 4 5 |
<action autorun="onstart">
callwhen(layer[p2].loaded AND layer[p3].loaded,
sync_multiple_viewers(get(global), get(layer[p2].krpano), get(layer[p3].krpano));
);
</action>
|
Benutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
that is even more interesting!
: https://pame.virtualtuur.com