kittycad_modeling_cmds/session.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::shared::PostEffectType;
5
6/// Params for starting the engine.
7#[derive(Debug, Serialize, Deserialize, JsonSchema)]
8#[serde(default)]
9pub struct EngineParams {
10 /// Width of the video feed. Must be a multiple of 4.
11 pub video_res_width: u32,
12 /// Height of the video feed. Must be a multiple of 4.
13 pub video_res_height: u32,
14 /// Frames per second of the video feed.
15 pub fps: u32,
16 /// If true, engine will render video frames as fast as it can.
17 pub unlocked_framerate: bool,
18 /// Engine Post effects (such as SSAO)
19 pub post_effect: Option<PostEffectType>,
20 /// If true, will start a webrtc connection.
21 pub webrtc: bool,
22 /// An optional identifier for a pool of engine instances.
23 /// The 'default' pool is used when none is specified.
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub pool: Option<String>,
26 /// If true, will show the grid at the start of the session.
27 pub show_grid: bool,
28 /// If given, when the session ends, the modeling commands sent during
29 /// the session will be written out to this filename.
30 /// For debugging.
31 pub replay: Option<String>,
32 /// API Call ID for distributed tracing
33 pub api_call_id: Option<String>,
34}
35
36impl Default for EngineParams {
37 fn default() -> Self {
38 Self {
39 video_res_width: 1280,
40 video_res_height: 720,
41 fps: 60,
42 unlocked_framerate: false,
43 post_effect: None,
44 webrtc: true,
45 pool: None,
46 show_grid: false,
47 replay: None,
48 api_call_id: None,
49 }
50 }
51}
52
53impl EngineParams {
54 /// Returns a default EngineParams with the grid enabled.
55 /// This is primarily useful for engine testing.
56 pub fn default_with_grid() -> Self {
57 Self {
58 show_grid: true,
59 ..Self::default()
60 }
61 }
62}