pub fn request_model<P: AsRef<Path>>(&self, path: P) -> Model {
        let mut state = self.state();

        if let Some(model) = state.find_model(path.as_ref()) {
            return model;
        }

        let model = Model::new(ResourceState::new_pending(path.as_ref().to_owned()));
        state.models.push(TimedEntry {
            value: model.clone(),
            time_to_live: DEFAULT_RESOURCE_LIFETIME,
        });

        let result = model.clone();
        let path = path.as_ref().to_owned();
        let resource_manager = self.clone();

        #[cfg(target_arch = "wasm32")]
        crate::core::wasm_bindgen_futures::spawn_local(async move {
            load_model(model, path, resource_manager).await;
        });

        #[cfg(not(target_arch = "wasm32"))]
        state.thread_pool.spawn_ok(async move {
            load_model(model, path, resource_manager).await;
        });

        result
    }
/// Tries to load new model resource from given path or get instance of existing, if any.
/// This method is asynchronous, it immediately returns a model which can be shared across
/// multiple places, the loading may fail, but it is internal state of the model. If you need
/// to access internals of the texture you have to get state first and then use pattern matching
/// to get ModelData which contains actual model data.
///
/// # Async/.await
///
/// Each model implements Future trait and can be used in async contexts.
///
/// # Supported formats
///
/// Currently only FBX (common format in game industry for storing complex 3d models)
/// and RGS (native rusty-editor format) formats are supported.
Tries to load new model resource from given path or get instance of existing, if any.
This method is asynchronous, it immediately returns a model which can be shared across
multiple places, the loading may fail, but it is internal state of the model. If you need
to access internals of the texture you have to get state first and then use pattern matching
to get ModelData which contains actual model data.
Tries to load new model resource from given path or get instance of existing if any . This method is asynchronous it immediately returns a model which can be shared across multiple places the loading may fail but it is internal state of the model . If you need to access internals of the texture you have to get state first and then use pattern matching to get ModelData which contains actual model data .
pub fn request_model<P: AsRef<Path>>(&self, path: P) -> Model {
        let mut state = self.state();
        if let Some(model) = state.find_model(path.as_ref()) {
            return model;
        }
        let model = Model::new(ResourceState::new_pending(path.as_ref().to_owned()));
        state.models.push(TimedEntry {
            value: model.clone(),
            time_to_live: DEFAULT_RESOURCE_LIFETIME,
        });
        let result = model.clone();
        let path = path.as_ref().to_owned();
        let resource_manager = self.clone();
        #[cfg(target_arch = "wasm32")]
        crate::core::wasm_bindgen_futures::spawn_local(async move {
            load_model(model, path, resource_manager).await;
        });
        #[cfg(not(target_arch = "wasm32"))]
        state.thread_pool.spawn_ok(async move {
            load_model(model, path, resource_manager).await;
        });
        result
    }
pub fn request_model < P : AsRef < Path > > ( & self , path : P ) -> Model { let mut state = self . state ( ) ; if let Some ( model ) = state . find_model ( path . as_ref ( ) ) { return model ; } let model = Model :: new ( ResourceState :: new_pending ( path . as_ref ( ) . to_owned ( ) ) ) ; state . models . push ( TimedEntry { value : model . clone ( ) , time_to_live : DEFAULT_RESOURCE_LIFETIME , } ) ; let result = model . clone ( ) ; let path = path . as_ref ( ) . to_owned ( ) ; let resource_manager = self . clone ( ) ; # [ cfg ( target_arch " " ) ] crate :: core :: wasm_bindgen_futures :: spawn_local ( async move { load_model ( model , path , resource_manager ) . await ; } ) ; # [ cfg ( not ( target_arch " " ) ) ] state . thread_pool . spawn_ok ( async move { load_model ( model , path , resource_manager ) . await ; } ) ; result }
Tries to load new model resource from given path or get instance of existing, if any.
Tries to load new model resource from given path or get instance of existing if any .
&self
path
P
async/.await
Each model implements Future trait and can be used in async contexts.
Each model implements Future trait and can be used in async contexts .
supported formats
Currently only FBX (common format in game industry for storing complex 3d models)
and RGS (native rusty-editor format) formats are supported.
Currently only FBX ( common format in game industry for storing complex 3d models ) and RGS ( native rusty - editor format ) formats are supported .