[][src]Struct crystal_engine::ModelHandle

pub struct ModelHandle { /* fields omitted */ }

A handle to the model that was loaded. This can be used to move the model around in the world.

When this handle is dropped, the model will disappear from the world on the next tick.

When this handle is cloned, a second model will appear in the world. Both models can be controlled independently.

Implementations

impl ModelHandle[src]

pub fn position(&self) -> Vector3<f32>[src]

Get the current position of the handle. This is short for self.read(|d| d.position)

pub fn rotation(&self) -> Euler<Rad<f32>>[src]

Get the current rotation of the handle. This is short for self.read(|d| d.rotation)

pub fn scale(&self) -> f32[src]

Get the current scale of the handle. This is short for self.read(|d| d.scale)

pub fn read<T>(&self, cb: impl FnOnce(&ModelData) -> T) -> T[src]

Read the data of the model. Optionally returning a value.

let handle: ModelHandle = game_state.new_triangle_model().build();
let scale = handle.read(|d| d.scale);

pub fn modify<T>(&self, cb: impl FnOnce(&mut ModelData) -> T) -> T[src]

Update the model model. Optionally returning a value.

let handle: ModelHandle = game_state.new_triangle_model().build();
handle.modify(|d| d.scale = 0.0 );

Trait Implementations

impl Clone for ModelHandle[src]

impl Drop for ModelHandle[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Content for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SafeBorrow<T> for T[src]

impl<T> SetParameter for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.