Class: Stagecraft::Cameras::Orthographic
- Defined in:
- lib/stagecraft/cameras/orthographic_camera.rb
Constant Summary collapse
- PROPERTIES =
%i[left right top bottom near far].freeze
Instance Attribute Summary
Attributes inherited from Node
#cast_shadow, #children, #name, #parent, #position, #receive_shadow, #render_order, #rotation, #scale, #visible, #world_version
Instance Method Summary collapse
-
#initialize(left: -1.0,, right: 1.0, top: 1.0, bottom: -1.0,, near: 0.1, far: 2_000.0) ⇒ Orthographic
constructor
A new instance of Orthographic.
- #projection_matrix ⇒ Object
Methods inherited from Camera
#view_matrix, #view_projection_matrix
Methods inherited from Node
#add, #find, #local_matrix, #look_at, #remove, #transform_dirty!, #traverse, #world_matrix, #world_matrix_with_version, #world_position
Constructor Details
#initialize(left: -1.0,, right: 1.0, top: 1.0, bottom: -1.0,, near: 0.1, far: 2_000.0) ⇒ Orthographic
Returns a new instance of Orthographic.
10 11 12 13 14 15 16 17 18 |
# File 'lib/stagecraft/cameras/orthographic_camera.rb', line 10 def initialize(left: -1.0, right: 1.0, top: 1.0, bottom: -1.0, near: 0.1, far: 2_000.0, **) super(**) @projection_revision = 0 @cached_projection_revision = -1 { left:, right:, top:, bottom:, near:, far: }.each do |name, value| public_send(:"#{name}=", value) end validate_extents! end |
Instance Method Details
#projection_matrix ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/stagecraft/cameras/orthographic_camera.rb', line 32 def projection_matrix return @projection_matrix if @cached_projection_revision == @projection_revision validate_extents! width = right - left height = top - bottom depth = far - near @projection_matrix = Larb::Mat4.new([ 2.0 / width, 0.0, 0.0, 0.0, 0.0, 2.0 / height, 0.0, 0.0, 0.0, 0.0, -1.0 / depth, 0.0, -(right + left) / width, -(top + bottom) / height, -near / depth, 1.0 ]) @cached_projection_revision = @projection_revision @projection_matrix end |