Skip to main content

kittycad_modeling_cmds/format/
fbx.rs

1use bon::Builder;
2use parse_display::{Display, FromStr};
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6/// Import models in FBX format.
7pub mod import {
8    use super::*;
9    /// Options for importing FBX.
10    #[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
11    #[serde(rename = "FbxImportOptions")]
12    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
13    #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
14    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
15    #[cfg_attr(
16        feature = "python",
17        pyo3_stub_gen::derive::gen_stub_pyclass,
18        pyo3::pyclass(name = "FbxImportOptions", from_py_object)
19    )]
20    #[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
21    pub struct Options {}
22
23    #[cfg(feature = "python")]
24    #[pyo3_stub_gen::derive::gen_stub_pymethods]
25    #[pyo3::pymethods]
26    impl Options {
27        #[new]
28        /// Set the options to their defaults.
29        pub fn new() -> Self {
30            Default::default()
31        }
32    }
33}
34
35/// Export models in FBX format.
36pub mod export {
37    use super::*;
38
39    /// Options for exporting FBX.
40    #[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
41    #[serde(rename = "FbxExportOptions")]
42    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
43    #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
44    #[cfg_attr(
45        feature = "python",
46        pyo3_stub_gen::derive::gen_stub_pyclass,
47        pyo3::pyclass(name = "FbxExportOptions", from_py_object)
48    )]
49    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
50    #[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
51    pub struct Options {
52        /// Specifies which kind of FBX will be exported.
53        pub storage: Storage,
54
55        /// Timestamp override.
56        pub created: Option<chrono::DateTime<chrono::Utc>>,
57    }
58
59    #[cfg(feature = "python")]
60    #[pyo3_stub_gen::derive::gen_stub_pymethods]
61    #[pyo3::pymethods]
62    impl Options {
63        #[new]
64        /// Set the options to their defaults.
65        pub fn new() -> Self {
66            Default::default()
67        }
68    }
69
70    /// Describes the storage format of an FBX file.
71    #[derive(
72        Default, Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr,
73    )]
74    #[display(style = "snake_case")]
75    #[serde(rename = "FbxStorage", rename_all = "snake_case")]
76    #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
77    #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
78    #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
79    #[cfg_attr(
80        feature = "python",
81        pyo3_stub_gen::derive::gen_stub_pyclass_enum,
82        pyo3::pyclass(name = "FbxStorage", from_py_object)
83    )]
84    #[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
85    pub enum Storage {
86        /// ASCII FBX encoding.
87        Ascii,
88
89        /// Binary FBX encoding.
90        #[default]
91        Binary,
92    }
93}