Skip to content

Commit

Permalink
Add Transform::new()
Browse files Browse the repository at this point in the history
  • Loading branch information
distransient committed Nov 28, 2018
1 parent 77285f6 commit 6a59ce5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions amethyst_core/src/transform/components/local_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,32 @@ pub struct Transform {
}

impl Transform {
/// Create a new Transform.
///
/// # Examples
///
/// ```rust
/// # use amethyst_core::transform::components::Transform;
/// # use amethyst_core::nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3};
/// let position = Translation3::new(0.0, 2.0, 4.0);
/// let rotation = UnitQuaternion::from_euler_angles(0.4, 0.2, 0.0);
/// let scale = Vector3::new(1.0, 1.0, 1.0);
///
/// let t = Transform::new(position, rotation, scale);
///
/// assert_eq!(t.translation().y, 2.0);
/// ```
pub fn new(
position: Translation3<f32>,
rotation: UnitQuaternion<f32>,
scale: Vector3<f32>,
) -> Self {
Transform {
iso: Isometry3::from_parts(position, rotation),
scale,
}
}

/// Makes the entity point towards `position`.
///
/// `up` says which direction the entity should be 'rolled' to once it is pointing at
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog][kc], and this project adheres to
* `sprite_camera_follow` example showing how to use a Camera that has a sprite Parent ([#1099])
* Added capabilities for the `DrawFlat2D` pass to draw `TextureHandle`s by themselves. Also added a simple example for this. ([#1153])
* Added a `Flipped` component which allows flipping sprites or images horizontally and vertically. ([#1153])
* Added transform constructor function `Transform::new()`. ([#1187])

### Changed

Expand Down Expand Up @@ -74,6 +75,9 @@ The format is based on [Keep a Changelog][kc], and this project adheres to
[#1131]: https://github.com/amethyst/amethyst/pull/1131
[#1153]: https://github.com/amethyst/amethyst/pull/1153
[#1164]: https://github.com/amethyst/amethyst/pull/1164
[#1142]: https://github.com/amethyst/amethyst/pull/1142
[#1052]: https://github.com/amethyst/amethyst/pull/1052
[#1187]: https://github.com/amethyst/amethyst/pull/1187
[winit_018]: https://github.com/tomaka/winit/blob/v0.18.0/CHANGELOG.md#version-0180-2018-11-07
[glutin_019]: https://github.com/tomaka/glutin/blob/master/CHANGELOG.md#version-0190-2018-11-09

Expand Down

0 comments on commit 6a59ce5

Please sign in to comment.