1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
5pub enum Projection {
6 #[default]
7 Equirectangular,
8 Cylindrical,
9}
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
13#[serde(rename_all = "lowercase")]
14pub enum OutputFormat {
15 #[default]
16 Jpeg,
17 Png,
18 #[cfg(feature = "webp")]
19 Webp,
20}
21
22impl OutputFormat {
23 #[must_use]
24 pub const fn to_extension(&self) -> &'static str {
25 match self {
26 Self::Jpeg => "jpg",
27 Self::Png => "png",
28 #[cfg(feature = "webp")]
29 Self::Webp => "webp",
30 }
31 }
32}
33
34#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
36#[serde(rename_all = "lowercase")]
37pub enum InterpolationMode {
38 Bilinear,
39 #[default]
40 Bicubic,
41}
42
43#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
45#[serde(rename_all = "lowercase")]
46pub enum DownscalingMethod {
47 #[default]
49 Recursive,
50 Direct,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct PanoAngles {
56 pub haov: f64,
58 pub vaov: f64,
60 pub v_offset: f64,
62 pub horizon_pixels: i32,
64 pub projection: Projection,
65 pub north_offset: Option<f64>,
67}
68
69impl Default for PanoAngles {
70 fn default() -> Self {
71 Self {
72 haov: 360.0,
73 vaov: 180.0,
74 v_offset: 0.0,
75 horizon_pixels: 0,
76 projection: Projection::default(),
77 north_offset: None,
78 }
79 }
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct OutputConfig {
84 pub tile_size: u32,
85 pub fallback_size: u32,
86 pub cube_size: u32,
87 pub format: OutputFormat,
88 pub quality: u8,
89 pub interpolation_mode: InterpolationMode,
90 pub yaw_padding: f64,
91 pub pitch_padding: f64,
92 pub background_color: [u8; 3],
94 pub downscaling_method: DownscalingMethod,
96}
97
98impl Default for OutputConfig {
99 fn default() -> Self {
100 Self {
101 tile_size: 512,
102 fallback_size: 1024,
103 cube_size: 0, format: OutputFormat::default(),
105 quality: 75,
106 interpolation_mode: InterpolationMode::default(),
107 background_color: [0, 0, 0],
108 yaw_padding: 0.0,
109 pitch_padding: 0.0,
110 downscaling_method: DownscalingMethod::default(),
111 }
112 }
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize, Default)]
117pub struct TilerConfig {
118 pub angles: PanoAngles,
119 pub output: OutputConfig,
120}
121
122#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
124#[serde(rename_all = "camelCase")]
125pub struct PannellumConfig {
126 #[serde(skip_serializing_if = "Option::is_none")]
127 pub haov: Option<f64>,
128 #[serde(skip_serializing_if = "Option::is_none")]
129 pub min_yaw: Option<f64>,
130 #[serde(skip_serializing_if = "Option::is_none")]
131 pub max_yaw: Option<f64>,
132 #[serde(skip_serializing_if = "Option::is_none")]
133 pub vaov: Option<f64>,
134 #[serde(skip_serializing_if = "Option::is_none")]
135 pub v_offset: Option<f64>,
136 #[serde(skip_serializing_if = "Option::is_none")]
137 pub min_pitch: Option<f64>,
138 #[serde(skip_serializing_if = "Option::is_none")]
139 pub max_pitch: Option<f64>,
140 #[serde(skip_serializing_if = "Option::is_none")]
141 pub background_color: Option<Vec<f64>>,
142 #[serde(skip_serializing_if = "Option::is_none")]
143 pub north_offset: Option<f64>,
144 #[serde(rename = "type")]
145 pub pano_type: String, pub multi_res: MultiResConfig,
147}
148
149#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
150#[serde(rename_all = "camelCase")]
151pub struct MultiResConfig {
152 #[serde(skip_serializing_if = "Option::is_none")]
153 pub missing_tiles: Option<String>,
154 pub path: String,
155 #[serde(skip_serializing_if = "Option::is_none")]
156 pub fallback_path: Option<String>,
157 pub extension: String,
158 pub tile_resolution: u32,
159 pub max_level: u32,
160 pub cube_resolution: u32,
161}