 
             for p in scene.active_particle_systems
                 p._eval()
+        
+        time2 = performance.now()
 
+        for scene_name in @context.loaded_scenes
             if scene.physics_enabled and (scene.rigid_bodies.length or scene.kinematic_characters.length)
                 get_last_char_phy scene.kinematic_characters
                 step_world scene.world, frame_duration * 0.001
                 phy_to_ob scene.rigid_bodies
+        
+        time3 = performance.now()
+
+        evaluate_all_animations @context, frame_duration
+        
+        time4 = performance.now()
 
         for name, video_texture of @context.video_textures
             #TODO: Optimize updating only the video_textures whose video is being played
             video_texture.update_texture?()
 
-        evaluate_all_animations @context, frame_duration
         # for s in @context.active_sprites
         #     s.evaluate_sprite frame_duration
         @context.render_manager.draw_all()
+
+        time5 = performance.now()
 
         for scene_name in @context.loaded_scenes
             scene = @context.scenes[scene_name]

class MainLoop

    constructor: (context)->
        # All milliseconds
        @frame_duration = 16
        @last_frame_durations = [16, 16, 16, 16, 16, 16, 16, 16, 16, 16]
        @_fdi = 0
        @timeout_time = context.MYOU_PARAMS.timeout
        @tasks_per_tick = context.MYOU_PARAMS.tasks_per_tick || 1

        @_bound_run = @run.bind @
        @_frame_callbacks = []
        @frame_number = 0
        @update_fps = null # assign a function to be called every 30 frames

    run: ->
        @stopped = false
