Transform
namespace Griff.Scenes;
public sealed class Transform : ComponentPosition, rotation and scale relative to the parent entity. Every entity has exactly one. Values are 3D so 2D and 3D share one model: 2D games use X/Y and rotate around Z.
Properties
Section titled “Properties”LocalMatrix
Section titled “LocalMatrix”public Matrix4x4 LocalMatrix { get; }Transform from this entity’s space to its parent’s space.
Position
Section titled “Position”public Vector3 Position { get; set; }Where it is, in world units, from its parent’s position (or the world’s middle, with none). Y is up.
Rotation
Section titled “Rotation”public Vector3 Rotation { get; set; }Euler angles in degrees, applied Z, then X, then Y. In 2D, Z is the rotation angle.
RotationDrawn
Section titled “RotationDrawn”public Vector3 RotationDrawn { get; }Its own Rotation (in its parent’s space) in the frame being drawn: between how it was turned as the last step began and how it is, as WorldMatrix turns it.
RotationQuaternion
Section titled “RotationQuaternion”public Quaternion RotationQuaternion { get; set; }public Vector3 Scale { get; set; }How many times its own size it’s drawn and collides: 2 is twice as big, -1 flips it. Children scale with it.
WorldMatrix
Section titled “WorldMatrix”public Matrix4x4 WorldMatrix { get; }Transform from this entity’s space to world space. Kept until it, or something it’s inside, moves. While a running game’s frame is being drawn, it’s where the entity is drawn: part way from where it was at the game’s last step but one to where it is (see Blend).
WorldPosition
Section titled “WorldPosition”public Vector3 WorldPosition { get; }Methods
Section titled “Methods”EulerDegrees
Section titled “EulerDegrees”public static Vector3 EulerDegrees(Quaternion rotation)A rotation as angles in degrees about X, Y and Z, as Rotation holds them (none for an empty quaternion).
FromEulerDegrees
Section titled “FromEulerDegrees”public static Quaternion FromEulerDegrees(Vector3 degrees)The rotation that angles in degrees about X, Y and Z make, as Rotation holds them.
Teleport
Section titled “Teleport”public void Teleport(Vector3 position)Moves it straight to position (in its parent’s space), drawn there from the next frame on rather than glided there over the step as ordinary movement is: for a respawn, a portal, wrapping round the screen. (Moves too far to have been made in one step are drawn that way anyway.)
Teleport
Section titled “Teleport”public void Teleport(Vector2 position)Like Teleport, keeping its Z.