(dt: number)
| 89 | } |
| 90 | |
| 91 | function advance(dt: number) { |
| 92 | const nextFrame = prevFrame |
| 93 | |
| 94 | for (let i = 0; i < currentFrame.length; i++) { |
| 95 | const animation = currentFrame[i] |
| 96 | priority = animation.priority |
| 97 | |
| 98 | // Animations may go idle before advancing. |
| 99 | if (!animation.idle) { |
| 100 | G.willAdvance(animation) |
| 101 | animation.advance(dt) |
| 102 | if (!animation.idle) { |
| 103 | nextFrame.push(animation) |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | priority = 0 |
| 108 | |
| 109 | // Reuse the `currentFrame` array to avoid garbage collection. |
| 110 | prevFrame = currentFrame |
| 111 | prevFrame.length = 0 |
| 112 | |
| 113 | // Set `currentFrame` for next frame, so the `start` function |
| 114 | // adds new animations to the proper array. |
| 115 | currentFrame = nextFrame |
| 116 | |
| 117 | return currentFrame.length > 0 |
| 118 | } |
| 119 | |
| 120 | /** Like `Array.prototype.findIndex` but returns `arr.length` instead of `-1` */ |
| 121 | function findIndex<T>(arr: T[], test: (value: T) => boolean) { |
no test coverage detected
searching dependent graphs…