@@ -4,12 +4,15 @@ divisions = span
4
4
5
5
var d1dims = 3
6
6
var mbjl_loop = true
7
- var vec_trails = 1
7
+ var vec_trails = 10
8
+ var end_wait_cycles = 4
9
+ var vecs_per_sec = 1
10
+
11
+ var end_cycles_waited = 0
8
12
var firstidx = 0
9
13
var lastidx = 0
10
- var last_valid_baseidx = data1 . length - 6
14
+ var last_valid_baseidx = data1 . length - 6 //need 2*3D points for a vector
11
15
var prev_incrt = 0
12
- var vecs_per_sec = 1
13
16
var vecs_delta_secs = 1 / vecs_per_sec
14
17
var incr_count = 0
15
18
view
18
21
height : dcols1 ,
19
22
expr : function ( emit , x , y , t , d ) {
20
23
var idx = x + y * drows1 // baseidx(x,y,t)
21
- if ( idx <= last_valid_baseidx && idx >= firstidx && idx <= lastidx ) {
22
- if ( vec_trails > 0 && incr_count > vec_trails && idx == firstidx ) {
24
+ if ( idx <= last_valid_baseidx
25
+ && idx >= firstidx && idx <= lastidx ) { //controls which vectors in path are shown
26
+ var lerpfraction = ( t - prev_incrt ) / vecs_delta_secs
27
+ if ( vec_trails > 0 && incr_count > vec_trails //interp/slide trailing bases in
28
+ && idx == firstidx //only the last visible base needs ot be interpolated
29
+ && end_cycles_waited == 0 //don't interpolate if holding/pausing at end of path anim
30
+ && idx + vec_trails * drows1 < last_valid_baseidx ) { //don't interpolate if it's the last base index (since we might be holding at the end)
23
31
emit (
24
32
mbbasic_lerp ( data1 [ idx ] , data1 [ idx + 3 ] , lerpfraction ) ,
25
33
mbbasic_lerp ( data1 [ idx + 1 ] , data1 [ idx + 4 ] , lerpfraction ) ,
28
36
} else {
29
37
emit ( data1 [ idx ] , data1 [ idx + 1 ] , data1 [ idx + 2 ] ) //bases
30
38
}
31
- lerpfraction = ( t - prev_incrt ) / vecs_delta_secs
32
- if ( idx == lastidx ) {
39
+ if ( idx == lastidx && end_cycles_waited == 0 ) {
33
40
emit (
34
41
mbbasic_lerp ( data1 [ idx ] , data1 [ idx + 3 ] , lerpfraction ) ,
35
42
mbbasic_lerp ( data1 [ idx + 1 ] , data1 [ idx + 4 ] , lerpfraction ) ,
42
49
if ( t - prev_incrt >= vecs_delta_secs ) {
43
50
lastidx += d1dims
44
51
incr_count += 1
45
- if ( vec_trails >= 0 && incr_count > vec_trails ) firstidx += d1dims
52
+ if ( vec_trails >= 0 && incr_count > vec_trails ) {
53
+ firstidx += d1dims
54
+ }
46
55
prev_incrt = t
47
56
if ( mbjl_loop && lastidx > last_valid_baseidx ) {
48
- firstidx = lastidx = 0
49
- incr_count = 0
57
+ if ( end_cycles_waited >= end_wait_cycles ) {
58
+ firstidx = lastidx = 0
59
+ incr_count = 0
60
+ end_cycles_waited = 0
61
+ } else {
62
+ //note after this is set we still wait a whole vecs_delta_secs
63
+ //till a potential restart
64
+ end_cycles_waited += 1
65
+ lastidx -= d1dims
66
+ if ( vec_trails >= 0 && incr_count > vec_trails ) {
67
+ firstidx -= d1dims
68
+ }
69
+ }
50
70
}
51
71
}
52
72
} ,
0 commit comments