Skip to main content

ModelResource

Type Alias ModelResource 

Source
pub type ModelResource = Resource<Model>;
Expand description

Type alias for model resources.

Aliased Type§

pub struct ModelResource { /* private fields */ }

Trait Implementations§

Source§

impl ModelResourceExtension for ModelResource

Source§

fn instantiate_from<Pre>( model: ModelResource, model_data: &Model, handle: Handle<Node>, dest_graph: &mut Graph, pre_processing_callback: &mut Pre, ) -> (Handle<Node>, NodeHandleMap<Node>)
where Pre: FnMut(Handle<Node>, &mut Node),

Copy the given model into the given graph.

  • model: The resource handle of the model, which put into the created nodes as their Base::resource to indicate which model the node was instantiated from.
  • model_data: A borrow of the data contained in model.
  • handle: The handle of the node within model that should be instantiated, typically the root of the model.
  • dest_graph: A mutable borrow of the node graph that will contain the newly created copy.
  • pre_processing_callback: A function that takes a node handle and a mutable node. The handle belongs to the original node in the model. The node is a copy of the original node, except that parent handle and child handles have been removed. This is a node that will be inserted into dest_graph.
Source§

fn begin_instantiation<'a>( &'a self, dest_scene: &'a mut Scene, ) -> InstantiationContext<'a>

Begins instantiation of the model.
Source§

fn instantiate(&self, dest_scene: &mut Scene) -> Handle<Node>

Tries to instantiate model from given resource.
Source§

fn instantiate_at( &self, scene: &mut Scene, position: Vector3<f32>, orientation: UnitQuaternion<f32>, ) -> Handle<Node>

Instantiates a prefab and places it at specified position and orientation in global coordinates.
Source§

fn instantiate_and_attach( &self, scene: &mut Scene, parent: Handle<impl ObjectOrVariant<Node>>, position: Vector3<f32>, face_towards: Vector3<f32>, scale: Vector3<f32>, ) -> Handle<Node>

Instantiates a prefab and places it at specified position, orientation, scale in global coordinates and attaches it to the specified parent. This method automatically calculates required local position, rotation, scaling for the instance so it will remain at the same place in world space after attachment. This method could be useful if you need to instantiate an object at some other object.
Source§

fn retarget_animations_directly( &self, root: Handle<Node>, graph: &Graph, ) -> Vec<Animation>

Tries to retarget animations from given model resource to a node hierarchy starting from root on a given scene. Read more
Source§

fn retarget_animations_to_player( &self, root: Handle<Node>, dest_animation_player: Handle<Node>, graph: &mut Graph, ) -> Vec<Handle<Animation>>

Tries to retarget animations from given model resource to a node hierarchy starting from root on a given scene. Unlike Self::retarget_animations_directly, it automatically adds retargetted animations to the specified animation player in the hierarchy of given root. Read more
Source§

fn retarget_animations( &self, root: Handle<Node>, graph: &mut Graph, ) -> Vec<Handle<Animation>>

Tries to retarget animations from given model resource to a node hierarchy starting from root on a given scene. Unlike Self::retarget_animations_directly, it automatically adds retargetted animations to a first animation player in the hierarchy of given root. Read more
Source§

fn generate_ids(&self) -> FxHashMap<Handle<Node>, SceneNodeId>

Generates a set of unique IDs for every node in the model. Use this method in pair with ModelResource::begin_instantiation.