pub fn from_model3(base: &Path, model3: &Model3) -> CubismResult<Self> {
        if let Some(moc_path) = model3.file_references.moc.as_ref() {
            let model = Model::from_bytes(&fs::read(base.join(moc_path))?)?;
            let mut this = Self::new(model);

            this.expressions = model3
                .file_references
                .expressions
                .iter()
                .map(|exp| {
                    Ok((
                        exp.name.clone(),
                        Expression::from_exp3_json(&this.model, base.join(&exp.file))?,
                    ))
                })
                .collect::<CubismResult<_>>()?;

            if let Some(eye_blink) = Self::try_create_eye_blink(&this.model, model3) {
                this.add_controller(crate::id::groups::EYE_BLINK.to_owned(), eye_blink);
            }

            Ok(this)
        } else {
            Err(io::Error::new(io::ErrorKind::NotFound, "no moc file has been specified").into())
        }
    }
/// Creates a UserModel from a Model3 and the parent path of the file it was
/// loaded from.
Creates a UserModel from a Model3 and the parent path of the file it was
loaded from.
Creates a UserModel from a Model3 and the parent path of the file it was loaded from .
pub fn from_model3(base: &Path, model3: &Model3) -> CubismResult<Self> {
        if let Some(moc_path) = model3.file_references.moc.as_ref() {
            let model = Model::from_bytes(&fs::read(base.join(moc_path))?)?;
            let mut this = Self::new(model);
            this.expressions = model3
                .file_references
                .expressions
                .iter()
                .map(|exp| {
                    Ok((
                        exp.name.clone(),
                        Expression::from_exp3_json(&this.model, base.join(&exp.file))?,
                    ))
                })
                .collect::<CubismResult<_>>()?;
            if let Some(eye_blink) = Self::try_create_eye_blink(&this.model, model3) {
                this.add_controller(crate::id::groups::EYE_BLINK.to_owned(), eye_blink);
            }
            Ok(this)
        } else {
            Err(io::Error::new(io::ErrorKind::NotFound, "no moc file has been specified").into())
        }
    }
pub fn from_model3 ( base : & Path , model3 : & Model3 ) -> CubismResult < Self > { if let Some ( moc_path ) = model3 . file_references . moc . as_ref ( ) { let model = Model :: from_bytes ( & fs :: read ( base . join ( moc_path ) ) ? ) ? ; let mut this = Self :: new ( model ) ; this . expressions = model3 . file_references . expressions . iter ( ) . map ( | exp | { Ok ( ( exp . name . clone ( ) , Expression :: from_exp3_json ( & this . model , base . join ( & exp . file ) ) ? , ) ) } ) . collect :: < CubismResult < _ > > ( ) ? ; if let Some ( eye_blink ) = Self :: try_create_eye_blink ( & this . model , model3 ) { this . add_controller ( crate :: id :: groups :: EYE_BLINK . to_owned ( ) , eye_blink ) ; } Ok ( this ) } else { Err ( io :: Error :: new ( io :: ErrorKind :: NotFound , " " ) . into ( ) ) } }
Creates a UserModel from a Model3 and the parent path of the file it was
loaded from.
Creates a UserModel from a Model3 and the parent path of the file it was loaded from .
base
&Path
model3
&Model3
base
&Path
model3
&Model3