Sie sind nicht angemeldet.

1

Donnerstag, 15. September 2022, 10:37

How to access other scene's hotspot info?

Hello,

I want to retrieve other scene's hotspot attributes and tried following code:

Zitat

hotspot[hotspotname].url);
This works only for the hotspots which are in the current scene.



So I tried adding scene information like this but doesn't work:

Zitat

get(scene[scenename].hotspot[hotspotname].url);

I thought all the XML information are accessible like JavaScript DOM -> Am I wrong?

Could someone explaing how this works?

Best Regards,
hyung

2

Donnerstag, 15. September 2022, 18:14

As far as I know, you can only get hotspots from a scene when the scene is loaded.
Hotspots are created when the scene starts and are deleted when the scene closes, so you can have hotspots with the same name in different scenes.
You can get hotspot data if it is global, i.e. keep="true"

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

3

Freitag, 16. September 2022, 09:42

Zitat

You can get hotspot data if it is global, i.e. keep="true"


or when you have them all defined in an array.

Tuur *thumbsup*

4

Freitag, 16. September 2022, 12:02

I thought all the XML information are accessible like JavaScript DOM -> Am I wrong?
yes... its not that simple.

the scenes are special... only the active scene is in the memory
or more precisely only the content of the active scene.

Quellcode

1
2
3
4
5
6
<scene name="a" test="a" ... /> 
	<hotspot name="a"... /> ... 
</scene>
<scene name="b" test="b" ... /> 
	<hotspot name="b"... /> ... 
</scene>

if you are in scene[a] ...
all other scenes attributes are available but not their content xml
eg. scene[b].test is available, but the scene[b] content xml (hotspot[b]) is not parsed / available

side note: it is possible to parse the special attribute scene[b].content,
but this is just a raw unparsed string ("<hotspot name="b"... /> ... ")
and not part of the active krpano data in memory.

layers & hotspots are removed on scene change, unless they have keep=true
but this does NOT mean you could access other scenes hotspots if they have keep=true
if that scene has not been loaded before also the hotspot doesn't exist.

the global xml is read once, the scene xml is integrated on scene loading
so if you need a hotspot/layer on for all scenes you define it global (outside of the scenes)

the global scene array only holds each scenes attributes. there is no scene[a].hotspot[a]
the scene content xml is parsed into the krpano global, eg hotspot[a]

these are main mechanisms of krpano.
*smile*

Dieser Beitrag wurde bereits 20 mal editiert, zuletzt von »indexofrefraction« (17. September 2022, 09:07)


5

Montag, 19. September 2022, 09:54

Hello indexofrefraction!

Thank you very much for your super clear explanation!! *thumbsup*

I believe Klaus built it this way for efficient memory management.

I think I can solve my problem by using hotspotname+events(onnewpano).

Thank you again for your explanation! *thumbup*

Best Regards,
hyung
I thought all the XML information are accessible like JavaScript DOM -> Am I wrong?
yes... its not that simple.

the scenes are special... only the active scene is in the memory
or more precisely only the content of the active scene.

Quellcode

1
2
3
4
	 ... 

 
	 ...

if you are in scene[a] ...
all other scenes attributes are available but not their content xml
eg. scene[b].test is available, but the scene[b] content xml (hotspot[b]) is not parsed / available

side note: it is possible to parse the special attribute scene[b].content,
but this is just a raw unparsed string (" ... ")
and not part of the active krpano data in memory.

layers & hotspots are removed on scene change, unless they have keep=true
but this does NOT mean you could access other scenes hotspots if they have keep=true
if that scene has not been loaded before also the hotspot doesn't exist.

the global xml is read once, the scene xml is integrated on scene loading
so if you need a hotspot/layer on for all scenes you define it global (outside of the scenes)

the global scene array only holds each scenes attributes. there is no scene[a].hotspot[a]
the scene content xml is parsed into the krpano global, eg hotspot[a]

these are main mechanisms of krpano.
*smile*[/b][/b][/b][/b]
[b]
[/b]
them

6

Montag, 19. September 2022, 10:02

Hello Tuur,

Zitat


or when you have them all defined in an array.

-> do you mean krpano array? Can you show an example of this?

Best Regards,
hyung


Zitat

You can get hotspot data if it is global, i.e. keep="true"


or when you have them all defined in an array.

Tuur *thumbsup*

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

7

Montag, 19. September 2022, 10:52

Hi,

here a simple example:
https://www.virtualtuur.com/krpano/120/help/hotspot_array/1/

xml:
https://www.virtualtuur.com/krpano/120/h…rray/1/tour.xml

Quellcode

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
    <arr name="htsp">
        <item name="s1" sc="scene_1" ath="10" atv="10" col="0x336699" click="loadscene(scene_2);" />
        <item name="s2" sc="scene_1" ath="20" atv="-10" col="0x000000" click="loadscene(scene_3);" />
        <item name="s3" sc="scene_2" ath="30" atv="-20" col="0xff0000" click="loadscene(scene_1);" />
        <item name="s4" sc="scene_2" ath="30" atv="20" col="0x00ffff" click="loadscene(scene_3);" />
        <item name="s5" sc="scene_3" ath="-20" atv="10" col="0xff0000" click="loadscene(scene_1);" />
        <item name="s6" sc="scene_3" ath="20" atv="10" col="0x0000ff" click="loadscene(scene_2);" />
    </arr>	 

    <events name="dohtsp" keep="true" onnewscene="CreateHotspots();" /> 
    
    <action name="CreateHotspots">
        for(set(i,0),i LT arr[htsp].item.count,inc(i),  
            copy(h, arr[htsp].item[get(i)]);

            if(get(h.sc) == xml.scene,
                addhotspot(get(h.name), hs);
                hs.loadstyle(htsp);
        
                set(hs,
                    ath=calc(h.ath),
                    atv=calc(h.atv),
                    bgcolor=calc(h.col),
                    onclick=calc(h.click)
                )
            )
        );
    </action>




Hope it helps,
Tuur *thumbsup*

8

Dienstag, 20. September 2022, 10:47

Hi Tuur!

Short codes but tell me lot of things!

Thank you for your example! *thumbsup*

Best Regards,
hyung



Hi,

here a simple example:
https://www.virtualtuur.com/krpano/120/help/hotspot_array/1/

xml:
https://www.virtualtuur.com/krpano/120/h…rray/1/tour.xml

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        for(set(i,0),i LT arr[htsp].item.count,inc(i),  
            copy(h, arr[htsp].item[get(i)]);

            if(get(h.sc) == xml.scene,
                addhotspot(get(h.name), hs);
                hs.loadstyle(htsp);
        
                set(hs,
                    ath=calc(h.ath),
                    atv=calc(h.atv),
                    bgcolor=calc(h.col),
                    onclick=calc(h.click)
                )
            )
        );




Hope it helps,
Tuur *thumbsup*