Trait Object

Source
pub trait Object: AsRef<Base> {
    type Data;

    // Required method
    fn resolve_data(&self, sync_guard: &SyncGuard<'_>) -> Self::Data;

    // Provided methods
    fn upcast(&self) -> Base { ... }
    fn set_visible(&self, visible: bool) { ... }
    fn set_name<S: Into<String>>(&self, name: S) { ... }
    fn set_transform<P, Q>(&self, pos: P, rot: Q, scale: f32)
       where Self: Sized,
             P: Into<Point3<f32>>,
             Q: Into<Quaternion<f32>> { ... }
    fn set_position<P>(&self, pos: P)
       where Self: Sized,
             P: Into<Point3<f32>> { ... }
    fn set_orientation<Q>(&self, rot: Q)
       where Self: Sized,
             Q: Into<Quaternion<f32>> { ... }
    fn set_scale(&self, scale: f32) { ... }
    fn set_weights(&self, weights: Vec<f32>) { ... }
    fn look_at<E, T>(&self, eye: E, target: T, up: Option<Vector3<f32>>)
       where Self: Sized,
             E: Into<Point3<f32>>,
             T: Into<Point3<f32>> { ... }
}
Expand description

Marks data structures that are able to added to the scene graph.

Required Associated Types§

Source

type Data

The internal data for the object.

Three-rs objects normally expose a write-only interface, making it possible to change an object’s internal values but not possible to read those values. SyncGuard::resolve_data allows for that data to be read in a controlled way, with. the data for the specific object type determined by the Data trait member.

Each object type has its own internal data, and not all object types can provide access to meaningful data. Types that cannot provide user-facing data will specify () for Data.

Required Methods§

Source

fn resolve_data(&self, sync_guard: &SyncGuard<'_>) -> Self::Data

Retrieves the internal data for the object.

Prefer to use SyncGuard::resolve_data over calling this directly.

Provided Methods§

Source

fn upcast(&self) -> Base

Converts into the base type.

Source

fn set_visible(&self, visible: bool)

Invisible objects are not rendered by cameras.

Source

fn set_name<S: Into<String>>(&self, name: S)

Sets the name of the object.

Source

fn set_transform<P, Q>(&self, pos: P, rot: Q, scale: f32)
where Self: Sized, P: Into<Point3<f32>>, Q: Into<Quaternion<f32>>,

Set both position, orientation and scale.

Source

fn set_position<P>(&self, pos: P)
where Self: Sized, P: Into<Point3<f32>>,

Set position.

Source

fn set_orientation<Q>(&self, rot: Q)
where Self: Sized, Q: Into<Quaternion<f32>>,

Set orientation.

Source

fn set_scale(&self, scale: f32)

Set scale.

Source

fn set_weights(&self, weights: Vec<f32>)

Set weights.

Source

fn look_at<E, T>(&self, eye: E, target: T, up: Option<Vector3<f32>>)
where Self: Sized, E: Into<Point3<f32>>, T: Into<Point3<f32>>,

Rotates object in the specific direction of target.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§