kittycad_modeling_cmds/format/
gltf.rs

1use parse_display::{Display, FromStr};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// Import models in KittyCAD's GLTF format.
6pub mod import {
7    use super::*;
8
9    /// Options for importing glTF 2.0.
10    #[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
11    #[display("")]
12    #[serde(rename = "GltfImportOptions")]
13    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
14    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
15    pub struct Options {}
16}
17
18/// Export models in KittyCAD's GLTF format.
19pub mod export {
20    use super::*;
21    /// Options for exporting glTF 2.0.
22    #[derive(Default, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)]
23    #[display("storage: {storage}, presentation: {presentation}")]
24    #[serde(rename = "GltfExportOptions")]
25    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
26    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
27    pub struct Options {
28        /// Specifies which kind of glTF 2.0 will be exported.
29        pub storage: Storage,
30        /// Specifies how the JSON will be presented.
31        pub presentation: Presentation,
32    }
33
34    /// Describes the storage format of a glTF 2.0 scene.
35    #[derive(
36        Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
37    )]
38    #[display(style = "snake_case")]
39    #[serde(rename = "GltfStorage", rename_all = "snake_case")]
40    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
41    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
42    pub enum Storage {
43        /// Binary glTF 2.0.
44        ///
45        /// This is a single binary with .glb extension.
46        Binary,
47
48        /// Standard glTF 2.0.
49        ///
50        /// This is a JSON file with .gltf extension paired with a separate
51        /// binary blob file with .bin extension.
52        Standard,
53
54        /// Embedded glTF 2.0.
55        ///
56        /// Single JSON file with .gltf extension binary data encoded as
57        /// base64 data URIs.
58        ///
59        /// This is the default setting.
60        #[default]
61        Embedded,
62    }
63
64    /// Describes the presentation style of the glTF JSON.
65    #[derive(
66        Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
67    )]
68    #[display(style = "snake_case")]
69    #[serde(rename = "GltfPresentation", rename_all = "snake_case")]
70    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
71    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
72    pub enum Presentation {
73        /// Condense the JSON into the smallest possible size.
74        Compact,
75
76        /// Expand the JSON into a more human readable format.
77        ///
78        /// This is the default setting.
79        #[default]
80        Pretty,
81    }
82}