diff --git a/leenkx/Sources/iron/system/Time.hx b/leenkx/Sources/iron/system/Time.hx index 7b6cd22..99484eb 100644 --- a/leenkx/Sources/iron/system/Time.hx +++ b/leenkx/Sources/iron/system/Time.hx @@ -8,21 +8,23 @@ class Time { return 1 / frequency; } - // TODO: set physics step from Blender's editor + static var _fixedStep: Null; public static var fixedStep(get, never): Float; static function get_fixedStep(): Float { - return 1 / 60; + return _fixedStep; } - public static var scale = 1.0; - public static var delta(get, never): Float; - static function get_delta(): Float { - if (frequency == null) initFrequency(); - return (1 / frequency) * scale; + + public static function initFixedStep(value: Float = 1 / 60) { + _fixedStep = value; } - static var last = 0.0; - public static var realDelta = 0.0; + + static var lastTime = 0.0; + public static var delta = 0.0; + + static var lastRenderTime = 0.0; + public static var renderDelta = 0.0; public static inline function time(): Float { return kha.Scheduler.time(); } @@ -37,7 +39,12 @@ class Time { } public static function update() { - realDelta = realTime() - last; - last = realTime(); + delta = (realTime() - lastTime) * scale; + lastTime = realTime(); + } + + public static function render() { + renderDelta = (realTime() - lastRenderTime) * scale; + lastRenderTime = realTime(); } }