Skip to main content

Transform

Struct Transform 

Source
pub struct Transform {
    pub position: Vec3,
    pub orientation: Quat,
    pub scale: Vec3,
}
Expand description

A world-space placement: position, orientation, and (optionally) scale. 一个世界空间中的放置:位置、朝向和(可选的)缩放。

Scale defaults to one and is intentionally distinct from position so a renderer or physics step can ignore it without ambiguity. 缩放默认为 1,并刻意与位置区分开,以便渲染器或物理步进能够毫无歧义地忽略它。

Fields§

§position: Vec3

Translation in world space. 世界空间中的平移。

§orientation: Quat

Rotation in world space. 世界空间中的旋转。

§scale: Vec3

Uniform or per-axis scale. 均匀或按轴缩放。

Implementations§

Source§

impl Transform

Source

pub const fn from_position(position: Vec3) -> Self

Place an object at position with identity rotation and unit scale. 在 position 处放置对象,旋转为单位旋转、缩放为单位缩放。

Source

pub const fn from_position_orientation( position: Vec3, orientation: Quat, ) -> Self

Place an object at position with the given orientation and unit scale. 在 position 处以给定的 orientation 放置对象,缩放为单位缩放。

Source

pub fn to_matrix(self) -> Mat4

Compose into a single model matrix (scale → rotate → translate). 组合成单个模型矩阵(缩放 → 旋转 → 平移)。

Source

pub fn forward(self) -> Vec3

Local +Z transformed into world space. 局部 +Z 轴变换到世界空间。

Source

pub fn up(self) -> Vec3

Local +Y transformed into world space. 局部 +Y 轴变换到世界空间。

Source

pub fn right(self) -> Vec3

Local +X transformed into world space. 局部 +X 轴变换到世界空间。

Trait Implementations§

Source§

impl Clone for Transform

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Transform

Source§

impl Debug for Transform

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Transform

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Transform

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Transform

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.