pub mod tokens;
mod schema;
mod traits;
pub use schema::{
CylinderLight, DiskLight, DistantLight, DomeLight, GeometryLight, LightAPI, LightFilter, LightListAPI, PortalLight,
RectLight, ShadowAPI, ShapingAPI, SphereLight,
};
pub use traits::{BoundableLight, Light, NonboundableLight};
use tokens::*;
macro_rules! impl_lux_schema {
(@base $ty:ident) => {
impl $crate::usd::SchemaBase for $ty {
const KIND: $crate::usd::SchemaKind = $crate::usd::SchemaKind::ConcreteTyped;
fn prim(&self) -> &$crate::usd::Prim {
&self.0
}
}
impl $crate::schemas::geom::Imageable for $ty {}
impl $crate::schemas::geom::Xformable for $ty {}
};
(xformable $ty:ident) => {
impl_lux_schema!(@base $ty);
};
(nonboundable_light $ty:ident) => {
impl_lux_schema!(@base $ty);
impl $crate::schemas::lux::Light for $ty {}
impl $crate::schemas::lux::NonboundableLight for $ty {}
};
(boundable_light $ty:ident) => {
impl_lux_schema!(@base $ty);
impl $crate::schemas::geom::Boundable for $ty {}
impl $crate::schemas::lux::Light for $ty {}
impl $crate::schemas::lux::BoundableLight for $ty {}
};
(applied_api $ty:ident) => {
impl $crate::usd::SchemaBase for $ty {
const KIND: $crate::usd::SchemaKind = $crate::usd::SchemaKind::SingleApplyApi;
fn prim(&self) -> &$crate::usd::Prim {
&self.0
}
}
};
}
pub(crate) use impl_lux_schema;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum TextureFormat {
#[default]
Automatic,
Latlong,
MirroredBall,
Angular,
CubeMapVerticalCross,
}
impl TextureFormat {
pub fn as_token(self) -> &'static str {
match self {
TextureFormat::Automatic => TEXTURE_FORMAT_AUTOMATIC,
TextureFormat::Latlong => TEXTURE_FORMAT_LATLONG,
TextureFormat::MirroredBall => TEXTURE_FORMAT_MIRRORED_BALL,
TextureFormat::Angular => TEXTURE_FORMAT_ANGULAR,
TextureFormat::CubeMapVerticalCross => TEXTURE_FORMAT_CUBE_MAP_VERTICAL_CROSS,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
TEXTURE_FORMAT_AUTOMATIC => TextureFormat::Automatic,
TEXTURE_FORMAT_LATLONG => TextureFormat::Latlong,
TEXTURE_FORMAT_MIRRORED_BALL => TextureFormat::MirroredBall,
TEXTURE_FORMAT_ANGULAR => TextureFormat::Angular,
TEXTURE_FORMAT_CUBE_MAP_VERTICAL_CROSS => TextureFormat::CubeMapVerticalCross,
_ => return None,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum PoleAxis {
#[default]
SceneUp,
Y,
Z,
}
impl PoleAxis {
pub fn as_token(self) -> &'static str {
match self {
PoleAxis::SceneUp => POLE_AXIS_SCENE_UP,
PoleAxis::Y => POLE_AXIS_Y,
PoleAxis::Z => POLE_AXIS_Z,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
POLE_AXIS_SCENE_UP => PoleAxis::SceneUp,
POLE_AXIS_Y => PoleAxis::Y,
POLE_AXIS_Z => PoleAxis::Z,
_ => return None,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum LightListCacheBehavior {
#[default]
ConsumeAndContinue,
ConsumeAndHalt,
Ignore,
}
impl LightListCacheBehavior {
pub fn as_token(self) -> &'static str {
match self {
LightListCacheBehavior::ConsumeAndContinue => CACHE_BEHAVIOR_CONSUME_AND_CONTINUE,
LightListCacheBehavior::ConsumeAndHalt => CACHE_BEHAVIOR_CONSUME_AND_HALT,
LightListCacheBehavior::Ignore => CACHE_BEHAVIOR_IGNORE,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
CACHE_BEHAVIOR_CONSUME_AND_CONTINUE => LightListCacheBehavior::ConsumeAndContinue,
CACHE_BEHAVIOR_CONSUME_AND_HALT => LightListCacheBehavior::ConsumeAndHalt,
CACHE_BEHAVIOR_IGNORE => LightListCacheBehavior::Ignore,
_ => return None,
})
}
}