Sie sind nicht angemeldet.

1

Samstag, 13. Februar 2010, 02:53

Perform action every time a scene is loaded completely

Hi,

I'm creating a rather large virtual tour with 25 scenes in it. In order to shorten the loading times I decided to preload the source images for every linked scene using this workaround. E.g. when a user is in scene 2, scene 1 and 3 have to preload.

I used the following code in every scene:
<events onloadcomplete="preloadpano(); set(event.onloadcomplete,null);>
<action name="preloadpano">...</action>


... but it only works for the first scene. I think this is because onloadcomplete works only once. Is there any other way to do this?

I definitely want to preload after the current scene is loaded completely, otherwise the preloading slows down the loading of the current scene.

2

Montag, 15. Februar 2010, 22:43

Hi,
... but it only works for the first scene. I think this is because onloadcomplete works only once. Is there any other way to do this?
it works only for the first scene, because in the "onloadcomplete" was set to 'null' after the first call,
see this code:

Quellcode

1
set(event.onloadcomplete,null);


just remove that,
or set separate <event> tags in every <scene> tag,

best regards,
Klaus

3

Dienstag, 16. Februar 2010, 15:53

Thanks Klaus! It's working now.

4

Donnerstag, 19. Januar 2012, 07:39

Perform action every time a scene is loaded completely

Is this action be place on every xml file? (when you main every scene?)

Or should be on the main xml file?

Your enlightenment will help a lot.

Thanks,

5

Sonntag, 22. Januar 2012, 20:25

Hi,

it should be in every <scene> but with the current version there is also an other possibility - using 'named' <event> elements - these elements will be removed automatically when loading a new pano/scene,

so define in every <scene> just: (so no need to set onloadcomplete back to null)

Quellcode

1
<events name="sceneevents" onloadcomplete="..." />


best regards,
Klaus

Ton den Ouden

Anfänger

Beiträge: 18

Wohnort: Netherlands

Beruf: Photographer

  • Nachricht senden

6

Montag, 26. März 2012, 09:39

Hi all,

I am using the preload procedure as described in the first post. It does work, but I found that it can be interupted by an action and the complete preload then seems to be lost.

Here is the situation where I try to use it: I made a tour for a car dealer who has 3 different showrooms.
It is possible to look round in every car in every showroom.
When loading a showroom, I call the preload like this and that seems to work fine as long as it is not interupted:

Quellcode

1
<events onloadcomplete="preloadpano2(); preloadauto1(); preloadauto2(); preloadauto3()"/>

But if I click on a hotspot to load a new scene (like any car in that showroom) before all images have completely preloaded I seem to loose all of them.
And returning to the showroom from the car does not start the preload again as I had hoped.

I wonder if I am doing something wrong, of if there is a better solution.

Thanks for any help!

Ton

7

Dienstag, 27. März 2012, 15:40

Hi,

how is your preload code looking like?
maybe try adding keep=true to the preloading elements to make sure that they will not be removed when loading an other pano/scene...

best regards,
Klaus

Ton den Ouden

Anfänger

Beiträge: 18

Wohnort: Netherlands

Beruf: Photographer

  • Nachricht senden

8

Mittwoch, 4. April 2012, 15:13

Thanks Klaus,

I finally found some time to do a number of tests, as I was not sure where to place the 'keep'.

It seems that the 'keep' does work like this, but I still have the problem that the preload is terminated when I click on a hotspot before all has been loaded.

My code for the preload looks like this:

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
29
30
31
32
33
34
35
<action name="preloadimage">
  <!-- 1. parameter = internal ID,  2. parameter = url -->
  addplugin(pre_%1);
  set(plugin[pre_%1].visible, false);
  set(plugin[pre_%1].onloaded, trace(preload %2 done);removeplugin(pre_%1) );
  set(plugin[pre_%1].url, %2);
  trace(starting preloading %2);
</action>

<action name="preloadpano1">
  preloadimage(showroom_1_l, %SWFPATH%/tour.data/images/showroom_1_l.jpg);
  preloadimage(showroom_1_f, %SWFPATH%/tour.data/images/showroom_1_f.jpg);
  preloadimage(showroom_1_r, %SWFPATH%/tour.data/images/showroom_1_r.jpg);
  preloadimage(showroom_1_b, %SWFPATH%/tour.data/images/showroom_1_b.jpg);
  preloadimage(showroom_1_u, %SWFPATH%/tour.data/images/showroom_1_u.jpg);
  preloadimage(showroom_1_d, %SWFPATH%/tour.data/images/showroom_1_d.jpg);
</action>

<action name="preloadauto1" keep="true">
  preloadimage(auto_1_f, %SWFPATH%/tour.data/images/12_f.jpg); 
  preloadimage(auto_1_r, %SWFPATH%/tour.data/images/12_r.jpg); 
  preloadimage(auto_1_l, %SWFPATH%/tour.data/images/12_l.jpg);  
  preloadimage(auto_1_b, %SWFPATH%/tour.data/images/12_b.jpg); 
  preloadimage(auto_1_u, %SWFPATH%/tour.data/images/12_u.jpg);  
  preloadimage(auto_1_d, %SWFPATH%/tour.data/images/12_d.jpg);  
</action>

<action name="preloadauto2" keep="true">
  preloadimage(auto_2_f, %SWFPATH%/tour.data/images/13_f.jpg); 
  preloadimage(auto_2_r, %SWFPATH%/tour.data/images/13_r.jpg); 
  preloadimage(auto_2_l, %SWFPATH%/tour.data/images/13_l.jpg);  
  preloadimage(auto_2_b, %SWFPATH%/tour.data/images/13_b.jpg);  
  preloadimage(auto_2_u, %SWFPATH%/tour.data/images/13_u.jpg);  
  preloadimage(auto_2_d, %SWFPATH%/tour.data/images/13_d.jpg);  
</action>


And this is how I embedded the preload command in the scene:

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
29
30
31
32
33
34
35
36
37
	<scene name="showroom_1" title="showroom_1" onstart="" >
		<view vlookat="0" fovtype="MFOV" fov="100" fovmin="85" fovmax="120" />
		<events onloadcomplete="preloadpano2(); preloadauto1(); preloadauto2(); preloadauto3()"/>
		
		<preview url="tour.data/images/showroom_1_preview.jpg" />
		
		<image>
			<left  url="tour.data/images/showroom_1_l.jpg" />
			<front url="tour.data/images/showroom_1_f.jpg" />
			<right url="tour.data/images/showroom_1_r.jpg" />
			<back  url="tour.data/images/showroom_1_b.jpg" />
			<up    url="tour.data/images/showroom_1_u.jpg" />
			<down  url="tour.data/images/showroom_1_d.jpg" />
		</image>

		<hotspot name="spot_auto_1" style="hotspot_ani" url="tour.data/graphics/stuur_ani.png" ath="-115" atv="-3"  scale="1" onhover="showtext('Opel Corsa 3 Drs ',hotspottextstyle)" 
			onclick="transition(spot_auto_1, -115.0, 0.0, 0, auto_1, -20, 0, 110)" />

		<hotspot name="spot_auto_2"   style="hotspot_ani" url="tour.data/graphics/stuur_ani.png" ath="-95" atv="-3"  scale="1" onhover="showtext('Opel Corsa 5 Drs ',hotspottextstyle)" 
			onclick="transition(spot_auto_2, -95.0, 0.0, 0, auto_2, 0, 0, 100)" />

		<hotspot name="spot_auto_3"   style="hotspot_ani" url="tour.data/graphics/stuur_ani.png" ath="-65" atv="-3"  scale="1" onhover="showtext('Opel Astra GTC ',hotspottextstyle)" 
			onclick="transition(spot_auto_3, -65.0, 0.0, 0, auto_3, 0, 0, 100)" />

		<hotspot name="spot_auto_4"   style="hotspot_ani" url="tour.data/graphics/stuur_ani.png" ath="10" atv="-4"  scale="1" onhover="showtext('Opel Astra Sports Tourer ',hotspottextstyle)" 
			onclick="transition(spot_auto_4, 10, 0.0, 0, auto_4, 0, 0, 100)" />

		<hotspot name="spot_auto_5"   style="hotspot_ani" url="tour.data/graphics/stuur_ani.png" ath="102" atv="-4"  scale="1" onhover="showtext('Opel Zafira Tourer ',hotspottextstyle)" 
			onclick="transition(spot_auto_5, 102, 0.0, 0, auto_5, 0, 0, 100)" />

		<hotspot name="spot_auto_7"   style="hotspot_ani" url="tour.data/graphics/stuur_ani.png" ath="172" atv="-4"  scale="1" onhover="showtext('Opel Astra 5 Drs ',hotspottextstyle)" 
			onclick="transition(spot_auto_7, 172.0, 0.0, 0, auto_7, 20, 0, 100)" />

		<hotspot name="spot_showroom_2"   style="hotspot_ani" url="tour.data/graphics/hotspot_i.png" ath="185" atv="-4"  scale="1"  
			onclick="transition(spot_showroom_2, 185, 0, 0, showroom_2, 45, 0, 90)" onhover="showtext('showroom 2',hotspottextstyle)"/>

	</scene>


I have only made a preload command for the first three cars in this test: http://www.pro4pics.com/test/den_hartog/tour.html

Thanks for having a look at it!

Ton

9

Mittwoch, 4. April 2012, 15:29

Hi,

add the keep=true in the preloadimage action for the preloaded image:

Quellcode

1
2
3
4
5
6
7
8
9
<action name="preloadimage">
  <!-- 1. parameter = internal ID,  2. parameter = url -->
  addplugin(pre_%1);
  set(plugin[pre_%1].visible, false);
  set(plugin[pre_%1].keep, true);
  set(plugin[pre_%1].onloaded, trace(preload %2 done);removeplugin(pre_%1) );
  set(plugin[pre_%1].url, %2);
  trace(starting preloading %2);
</action>


best regards,
Klaus

Ton den Ouden

Anfänger

Beiträge: 18

Wohnort: Netherlands

Beruf: Photographer

  • Nachricht senden

10

Freitag, 6. April 2012, 10:27

This makes the difference Klaus! All images are now loaded first and not interupted anymore if I click on a hotspot.

Thanks again!

Ton