Created
November 7, 2025 03:07
-
-
Save JohnGemstone/453d69ecfffeedfaf7f2363befb3b2af to your computer and use it in GitHub Desktop.
AfterEffects trolly loop for accumulating values over each iteration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| loopDur = key(numKeys).time - key(1).time; | |
| // only run while this layer is active | |
| if (time < inPoint) { | |
| // before layer starts → hold first keyframe | |
| key(1).value; | |
| } else if (time > outPoint) { | |
| // after layer ends → hold the final accumulated value at outPoint | |
| tEnd = outPoint - key(1).time; | |
| loopCountEnd = Math.floor(tEnd / loopDur); | |
| tInLoopEnd = (tEnd % loopDur) + key(1).time; | |
| loopValueEnd = valueAtTime(tInLoopEnd); | |
| offsetEnd = (key(numKeys).value - key(1).value) * loopCountEnd; | |
| loopValueEnd + offsetEnd; | |
| } else { | |
| // active portion → normal accumulation | |
| t = time - key(1).time; | |
| loopCount = Math.floor(t / loopDur); | |
| tInLoop = (t % loopDur) + key(1).time; | |
| loopValue = valueAtTime(tInLoop); | |
| offset = (key(numKeys).value - key(1).value) * loopCount; | |
| loopValue + offset; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment