You are not logged in.

1

Thursday, December 17th 2020, 6:53pm

better animation loop for hotspot image sequence

Hi all,
I was looking for a way to create an image loop based on the washing machine example:
[https://krpano.com/krpano.html?xml=temp/…chmaschinen.xml ]
I succeeded at last, but only by creating a "restart"-action which has an empty tween method...
If I leave that out, the framenumber has no reset.
There has to be a better method for this,
but at the moment I can't werap my head aroiund this...
Also, the update_frame call in the tween method is called far to often.
Any help is appreciated -
I will build an awesome demo example with this!

Here is my code

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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<krpano>

    <style 
    	name="spotstyle" 
    	distorted  ="true" 
    	enabled	="false" 
    	alpha  	="0.0"
    	zorder 	= "2"
    	onloaded="calc_pos_from_hfov_yaw_pitch_roll(159, -2.8, 29.6, -0.0);" 
    />

    <action name="animate">
    	// showlog(); trace(' active');
    	txtadd(distanceparameter, 'distance(', get(hotspot[%1].maxframes), ',', get(hotspot[%1].frametime), ')'); 
    	if(hotspot[%1].state == 'stop',
    			set(hotspot[%1].state, 'start');
    			tween(hotspot[%1].startframe, get(hotspot[%1].maxframes), get(distanceparameter), linear, restart(%1), update_frame(%1) );
//,
    		//	set(hotspot[%1].state, 'stop');
    		//	tween(hotspot[%1].startframe, 1, get(distanceparameter), linear, restart(%1), update_frame(%1) );
    	);
    </action>
    
    <action name="restart">
    	trace('restart');
    	// trace(%1);
    	
    	//txtadd(lastframe, get(hotspot[%1].framename), get(hotspot[%1].maxframes) );
    	//set(hotspot[get(lastframe)].alpha,0.0);
    	set(hotspot[%1].state, 'stop');
    	tween(hotspot[%1].startframe, 1, 0, linear, null, null );

    	delayedcall(0, animate( %1 ) );
    </action>

	<action name="update_frame">
    	copy(framenumber, hotspot[%1].startframe);
    	Math.floor(framenumber);
    	// trace('framenumber ',framenumber,' active');

    	for( set(i,1), i LE hotspot[%1].maxframes, inc(i),
    		txtadd(thisframe, get(hotspot[%1].framename), get(i) );
    		if(i == framenumber, 
    			set(hotspot[get(thisframe)].alpha,1.0)
    		, 
    			set(hotspot[get(thisframe)].alpha,0.0) 
    		); 
    	);
    </action>
    
    <!-- based on hugin stitching: https://krpano.com/forum/wbb/index.php?page=Thread&postID=38120#post38120 -->

    <!-- these are the frames  -->
	<!-- these are the frames  -->
    <hotspot name="pool1"  style="spotstyle" url="scene01/spot01/frame-01.jpg" />
    <hotspot name="pool2"  style="spotstyle" url="scene01/spot01/frame-02.jpg" />
    <hotspot name="pool3"  style="spotstyle" url="scene01/spot01/frame-03.jpg" />
    <hotspot name="pool4"  style="spotstyle" url="scene01/spot01/frame-04.jpg" />
    <hotspot name="pool5"  style="spotstyle" url="scene01/spot01/frame-05.jpg" />
    <hotspot name="pool6"  style="spotstyle" url="scene01/spot01/frame-06.jpg" />
    <hotspot name="pool7"  style="spotstyle" url="scene01/spot01/frame-07.jpg" />
    <hotspot name="pool8"  style="spotstyle" url="scene01/spot01/frame-08.jpg" />
    <hotspot name="pool9"  style="spotstyle" url="scene01/spot01/frame-09.jpg" />
    <hotspot name="pool10" style="spotstyle" url="scene01/spot01/frame-10.jpg" />
    <hotspot name="pool11" style="spotstyle" url="scene01/spot01/frame-11.jpg" />
    <hotspot name="pool12" style="spotstyle" url="scene01/spot01/frame-12.jpg" />
    <hotspot name="pool13" style="spotstyle" url="scene01/spot01/frame-13.jpg" />
    <hotspot name="pool14" style="spotstyle" url="scene01/spot01/frame-14.jpg" />
    <hotspot name="pool15" style="spotstyle" url="scene01/spot01/frame-15.jpg" />
 	<hotspot name="pool16" style="spotstyle" url="scene01/spot01/frame-16.jpg" />
    <hotspot name="pool17" style="spotstyle" url="scene01/spot01/frame-17.jpg" />
    <hotspot name="pool18" style="spotstyle" url="scene01/spot01/frame-18.jpg" />
    <hotspot name="pool19" style="spotstyle" url="scene01/spot01/frame-19.jpg" />
    <hotspot name="pool20" style="spotstyle" url="scene01/spot01/frame-20.jpg" />
    <hotspot name="pool21" style="spotstyle" url="scene01/spot01/frame-21.jpg" />
    <hotspot name="pool22" style="spotstyle" url="scene01/spot01/frame-22.jpg" />
    <hotspot name="pool23" style="spotstyle" url="scene01/spot01/frame-23.jpg" />
    <hotspot name="pool24" style="spotstyle" url="scene01/spot01/frame-24.jpg" />
    <hotspot name="pool25" style="spotstyle" url="scene01/spot01/frame-25.jpg" />
<!-- this is the animated hotspot -->
    <hotspot name  ="pool_animated"
    	url    	="scene01/spot01/frame-02.jpg"
    	distorted  ="true"
    	enabled	="false"
    	zorder 	= "0"
    	alpha  	="1.0"
    	startframe ="1"
    	maxframes  ="50"
    	frametime  ="4"
    	framename  ="pool" 
    	state  	="stop"
    	onloaded   ="calc_pos_from_hfov_yaw_pitch_roll(159, -2.8, 29.6, -0.0); animate(get(name));" 
    />

</krpano>

Thank you in advance and best regards,
MT