#[cfg(feature = "KHR_texture_transform")]
use crate::{extras::Extras, validation::Validate};
use gltf_derive::Validate;
use serde_derive::{Deserialize, Serialize};
#[cfg(feature = "extensions")]
use serde_json::{Map, Value};
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct Sampler {
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct Texture {
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
pub struct Info {
#[cfg(feature = "KHR_texture_transform")]
#[serde(
default,
rename = "KHR_texture_transform",
skip_serializing_if = "Option::is_none"
)]
pub texture_transform: Option<TextureTransform>,
#[cfg(feature = "extensions")]
#[serde(default, flatten)]
pub others: Map<String, Value>,
}
#[cfg(feature = "KHR_texture_transform")]
#[derive(Clone, Debug, Default, Deserialize, Serialize, Validate)]
#[serde(default, rename_all = "camelCase")]
pub struct TextureTransform {
pub offset: TextureTransformOffset,
pub rotation: TextureTransformRotation,
pub scale: TextureTransformScale,
pub tex_coord: Option<u32>,
#[cfg_attr(feature = "extras", serde(skip_serializing_if = "Option::is_none"))]
#[cfg_attr(not(feature = "extras"), serde(skip_serializing))]
pub extras: Extras,
}
#[cfg(feature = "KHR_texture_transform")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct TextureTransformOffset(pub [f32; 2]);
#[cfg(feature = "KHR_texture_transform")]
impl Default for TextureTransformOffset {
fn default() -> Self {
Self([0.0, 0.0])
}
}
#[cfg(feature = "KHR_texture_transform")]
impl Validate for TextureTransformOffset {}
#[cfg(feature = "KHR_texture_transform")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct TextureTransformRotation(pub f32);
#[cfg(feature = "KHR_texture_transform")]
impl Default for TextureTransformRotation {
fn default() -> Self {
Self(0.0)
}
}
#[cfg(feature = "KHR_texture_transform")]
impl Validate for TextureTransformRotation {}
#[cfg(feature = "KHR_texture_transform")]
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub struct TextureTransformScale(pub [f32; 2]);
#[cfg(feature = "KHR_texture_transform")]
impl Default for TextureTransformScale {
fn default() -> Self {
Self([1.0, 1.0])
}
}
#[cfg(feature = "KHR_texture_transform")]
impl Validate for TextureTransformScale {}