@name stest8
@inputs 
@outputs Left Right Side Frac
@persist [DT CT] [NPos TPos LPos MPos]:vector
@trigger none


if ( first() ) {
    
    
    
    for (I = 1, 4) {
        holoCreate(I)
        holoScaleUnits(I, vec(6))
        holoColor(I, hsv2rgb((360/3)*I, 1, 1))
    }
    
    
    NPos = TPos = LPos = MPos = holoEntity(1):pos() + vec(0, 0, 0)
    
    function number linear( Y0, Y1, T ) {
        return Y0 + T * (Y1 - Y0)
    }

    function number cosine( Y0, Y1, T ) {
        return linear( Y0, Y1, -cosr( pi() * T ) / 2 + 0.5 )
    }
        
    
    
}

interval(60)

DT = min(curtime() - CT, 60/1000)
CT = curtime()

StepFreq = 1
StepLength = 100
StepHeight = StepLength/3

if (Side == 0) {
    Left  = min(Left + DT, StepFreq)
    Frac  = cosine(0, 1, Left/StepFreq)
    
    NPos = bezier(LPos, MPos, TPos, Frac)
    
    holoPos(3, NPos)

    if (Left == StepFreq) {
        Left = 0
        Side++
        
        NPos = TPos
        LPos = TPos
        TPos = LPos + vec(1, 0, 0)*StepLength
         MPos = (LPos + TPos)/2 + vec(0, 0, StepHeight)
    }
}

if (Side == 1) {
    Right = min(Right + DT, StepFreq) 
    Frac  = cosine(0, 1, Right/StepFreq)

    NPos = bezier(LPos, MPos, TPos, Frac)
    
    holoPos(4, NPos)

    if (Right == StepFreq) {
        Right = 0
        Side--
        
        NPos = TPos
        LPos = TPos
        TPos = LPos + vec(1, 0, 0)*StepLength
        MPos = (LPos + TPos)/2 + vec(0, 0, StepHeight)
    }
}

#holoPos(1, LPos)
#holoPos(2, TPos)


#NPos = mix(TPos, LPos, Frac)
#holoPos(1, NPos)

