diff --git a/editor/src/messages/broadcast/broadcast_event.rs b/editor/src/messages/broadcast/broadcast_event.rs index c0f5f96a56..ebe2318aae 100644 --- a/editor/src/messages/broadcast/broadcast_event.rs +++ b/editor/src/messages/broadcast/broadcast_event.rs @@ -3,6 +3,7 @@ use crate::messages::prelude::*; #[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, Hash)] #[impl_message(Message, BroadcastMessage, TriggerEvent)] pub enum BroadcastEvent { + /// Triggered by requestAnimationFrame in JS AnimationFrame, CanvasTransformed, ToolAbort, diff --git a/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs b/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs index b78022575d..bf90e5881f 100644 --- a/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs +++ b/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs @@ -4,6 +4,7 @@ use crate::messages::input_mapper::utility_types::misc::FrameTimeInfo; use crate::messages::portfolio::utility_types::KeyboardPlatformLayout; use crate::messages::prelude::*; use glam::DVec2; +use std::time::Duration; pub struct InputPreprocessorMessageData { pub keyboard_platform: KeyboardPlatformLayout, @@ -97,6 +98,7 @@ impl MessageHandler for InputPreprocessorMessage::CurrentTime { timestamp } => { responses.add(AnimationMessage::SetTime(timestamp as f64)); self.time = timestamp; + self.frame_time.advance_timestamp(Duration::from_millis(timestamp)); } InputPreprocessorMessage::WheelScroll { editor_mouse_state, modifier_keys } => { self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses); diff --git a/frontend/wasm/src/editor_api.rs b/frontend/wasm/src/editor_api.rs index f7491b0ae9..013be96427 100644 --- a/frontend/wasm/src/editor_api.rs +++ b/frontend/wasm/src/editor_api.rs @@ -152,6 +152,12 @@ impl EditorHandle { for message in editor.handle_message(AnimationMessage::IncrementFrameCounter) { handle.send_frontend_message_to_js(message); } + + // Used by auto-panning, but this could possibly be refactored in the future, see: + // + for message in editor.handle_message(BroadcastMessage::TriggerEvent(BroadcastEvent::AnimationFrame)) { + handle.send_frontend_message_to_js(message); + } }); }