use anyhow::Result;
use crate::sdf::{Path, Value, Variability};
use crate::usd::Stage;
pub(super) use crate::schemas::common::{author_bool, author_float, author_rel_targets, author_uniform_token};
pub(super) fn author_uniform_bool(stage: &Stage, prim: &Path, name: &str, value: bool) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "bool")?
.set_variability(Variability::Uniform)?
.set_custom(false)?
.set(Value::Bool(value))?;
Ok(())
}
pub(super) fn author_vector3f(stage: &Stage, prim: &Path, name: &str, value: [f32; 3]) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "vector3f")?
.set_custom(false)?
.set(Value::Vec3f(value))?;
Ok(())
}
pub(super) fn author_point3f(stage: &Stage, prim: &Path, name: &str, value: [f32; 3]) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "point3f")?
.set_custom(false)?
.set(Value::Vec3f(value))?;
Ok(())
}
pub(super) fn author_float3(stage: &Stage, prim: &Path, name: &str, value: [f32; 3]) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "float3")?
.set_custom(false)?
.set(Value::Vec3f(value))?;
Ok(())
}
pub(super) fn author_quatf(stage: &Stage, prim: &Path, name: &str, value: [f32; 4]) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "quatf")?
.set_custom(false)?
.set(Value::Quatf(value))?;
Ok(())
}
pub(super) fn author_string(stage: &Stage, prim: &Path, name: &str, value: impl Into<String>) -> Result<()> {
let attr_path = prim.append_property(name)?;
stage
.create_attribute(attr_path, "string")?
.set_custom(false)?
.set(Value::String(value.into()))?;
Ok(())
}