Class: Transform
- Inherits:
-
Struct
- Object
- Struct
- Transform
- Defined in:
- lib/belts_engine/components/transform.rb
Instance Attribute Summary collapse
-
#position ⇒ Object
Returns the value of attribute position.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#scale ⇒ Object
Returns the value of attribute scale.
Instance Method Summary collapse
- #back ⇒ Object
- #down ⇒ Object
- #forward ⇒ Object
-
#initialize(position: Vec3.zero, rotation: Vec3.zero, scale: Vec3.one) ⇒ Transform
constructor
A new instance of Transform.
- #left ⇒ Object
- #right ⇒ Object
- #to_matrix ⇒ Object
- #up ⇒ Object
Constructor Details
Instance Attribute Details
#position ⇒ Object
Returns the value of attribute position
1 2 3 |
# File 'lib/belts_engine/components/transform.rb', line 1 def position @position end |
#rotation ⇒ Object
Returns the value of attribute rotation
1 2 3 |
# File 'lib/belts_engine/components/transform.rb', line 1 def rotation @rotation end |
#scale ⇒ Object
Returns the value of attribute scale
1 2 3 |
# File 'lib/belts_engine/components/transform.rb', line 1 def scale @scale end |
Instance Method Details
#back ⇒ Object
25 |
# File 'lib/belts_engine/components/transform.rb', line 25 def back = -forward |
#down ⇒ Object
27 |
# File 'lib/belts_engine/components/transform.rb', line 27 def down = -up |
#forward ⇒ Object
10 11 12 13 |
# File 'lib/belts_engine/components/transform.rb', line 10 def forward matrix = to_matrix Vec3[matrix[0, 2], matrix[1, 2], matrix[2, 2]] end |
#left ⇒ Object
26 |
# File 'lib/belts_engine/components/transform.rb', line 26 def left = -right |
#right ⇒ Object
15 16 17 18 |
# File 'lib/belts_engine/components/transform.rb', line 15 def right matrix = to_matrix Vec3[matrix[0, 0], matrix[1, 0], matrix[2, 0]] end |
#to_matrix ⇒ Object
4 5 6 7 8 |
# File 'lib/belts_engine/components/transform.rb', line 4 def to_matrix Mat4.translation(*position) * Mat4.rotation(*rotation) * Mat4.scale(*scale) end |
#up ⇒ Object
20 21 22 23 |
# File 'lib/belts_engine/components/transform.rb', line 20 def up matrix = to_matrix Vec3[matrix[0, 1], matrix[1, 1], matrix[2, 1]] end |