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}
33
34impl Default for EngineParams {
35 fn default() -> Self {
36 Self {
37 video_res_width: 1280,
38 video_res_height: 720,
39 fps: 60,
40 unlocked_framerate: false,
41 post_effect: None,
42 webrtc: true,
43 pool: None,
44 show_grid: false,
45 replay: None,
46 }
47 }
48}
49
50impl EngineParams {
51 /// Returns a default EngineParams with the grid enabled.
52 /// This is primarily useful for engine testing.
53 pub fn default_with_grid() -> Self {
54 Self {
55 show_grid: true,
56 ..Self::default()
57 }
58 }
59}