use anyhow::Result;
use crate::sdf::{Path, Value};
use crate::usd::Stage;
use crate::schemas::lux::tokens::{A_TREAT_AS_LINE, A_TREAT_AS_POINT};
pub(super) use crate::schemas::common::{author_rel_targets, varying_attribute};
pub(super) fn author_input_float(stage: &Stage, prim: &Path, name: &str, value: f32) -> Result<()> {
varying_attribute(stage, prim, name, "float")?.set(Value::Float(value))?;
Ok(())
}
pub(super) fn author_input_bool(stage: &Stage, prim: &Path, name: &str, value: bool) -> Result<()> {
varying_attribute(stage, prim, name, "bool")?.set(Value::Bool(value))?;
Ok(())
}
pub(super) fn author_input_color3f(stage: &Stage, prim: &Path, name: &str, value: [f32; 3]) -> Result<()> {
varying_attribute(stage, prim, name, "color3f")?.set(Value::Vec3f(value))?;
Ok(())
}
pub(super) fn author_input_asset(stage: &Stage, prim: &Path, name: &str, value: impl Into<String>) -> Result<()> {
varying_attribute(stage, prim, name, "asset")?.set(Value::AssetPath(value.into()))?;
Ok(())
}
pub(super) fn author_treat_as_point(stage: &Stage, prim: &Path, value: bool) -> Result<()> {
let attr_path = prim.append_property(A_TREAT_AS_POINT)?;
stage
.create_attribute(attr_path, "bool")?
.set_custom(false)?
.set(Value::Bool(value))?;
Ok(())
}
pub(super) fn author_treat_as_line(stage: &Stage, prim: &Path, value: bool) -> Result<()> {
let attr_path = prim.append_property(A_TREAT_AS_LINE)?;
stage
.create_attribute(attr_path, "bool")?
.set_custom(false)?
.set(Value::Bool(value))?;
Ok(())
}