Skip to content

Commit

Permalink
fix: set delta at the callback level when not throttled
Browse files Browse the repository at this point in the history
  • Loading branch information
verekia committed Oct 15, 2024
1 parent 4f129ee commit 3dee7c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/main-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const mainLoop = (time: number) => {

state.time = time
state.timeRunning += state.time - previousTime
state.delta = (state.time - previousTime) / 1000

let callbackCount = 0
for (const callbacksSet of callbacks.values()) {
Expand Down Expand Up @@ -67,6 +66,8 @@ export const addMainLoopEffect = (
if (throttleInterval === 0) {
// No throttling, execute every frame
callbackLastExecutions.set(callback, state.time)

state.delta = (state.time - previousTime) / 1000
callback(state)
} else {
// Calculate the number of intervals passed
Expand Down

0 comments on commit 3dee7c5

Please sign in to comment.