Class: Mittsu::OrthographicCamera

Inherits:
Camera show all
Defined in:
lib/mittsu/cameras/orthographic_camera.rb

Constant Summary

Constants inherited from Object3D

Mittsu::Object3D::DefaultUp

Instance Attribute Summary collapse

Attributes inherited from Camera

#matrix_world_inverse, #projection_matrix

Attributes inherited from Object3D

#active, #cast_shadow, #children, #frustum_culled, #geometry, #id, #initted, #matrix, #matrix_auto_update, #matrix_world, #matrix_world_needs_update, #model_view_matrix, #morph_target_influences, #name, #parent, #position, #quaternion, #receive_shadow, #render_order, #renderer, #rotation, #rotation_auto_update, #scale, #type, #up, #user_data, #uuid, #visible

Instance Method Summary collapse

Methods inherited from Camera

#get_world_direction, #look_at

Methods inherited from Object3D

#active?, #add, #add_opengl_object, #apply_matrix, #buffer_material, #deinit, #get_object_by_id, #get_object_by_name, #get_object_by_property, #get_world_direction, #get_world_position, #get_world_quaternion, #get_world_rotation, #get_world_scale, #init, #init_geometry, #load_uniforms_matrices, #local_to_world, #look_at, #print_tree, #project, #raycast, #remove, #rotate_on_axis, #rotate_x, #rotate_y, #rotate_z, #set_rotation_from_axis_angle, #set_rotation_from_euler, #set_rotation_from_matrix, #set_rotation_from_quaternion, #setup_matrices, #to_json, #to_s, #translate_on_axis, #translate_x, #translate_y, #translate_z, #traverse, #traverse_ancestors, #traverse_visible, #update_matrix, #update_matrix_world, #world_to_local

Methods included from EventDispatcher

#add_event_listener, #dispatch_event, #has_event_listener, #remove_event_listener

Constructor Details

#initialize(left, right, top, bottom, near = 0.1, far = 2000.0) ⇒ OrthographicCamera

Returns a new instance of OrthographicCamera.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 5

def initialize(left, right, top, bottom, near = 0.1, far = 2000.0)
  super()

  @type = 'OrthographicCamera'

  @zoom = 1.0

  @left = left.to_f
  @right = right.to_f
  @top = top.to_f
  @bottom = bottom.to_f

  @near = near.to_f
  @far = far.to_f

  update_projection_matrix
end

Instance Attribute Details

#bottomObject

Returns the value of attribute bottom.



3
4
5
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 3

def bottom
  @bottom
end

#farObject

Returns the value of attribute far.



3
4
5
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 3

def far
  @far
end

#leftObject

Returns the value of attribute left.



3
4
5
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 3

def left
  @left
end

#nearObject

Returns the value of attribute near.



3
4
5
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 3

def near
  @near
end

#rightObject

Returns the value of attribute right.



3
4
5
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 3

def right
  @right
end

#topObject

Returns the value of attribute top.



3
4
5
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 3

def top
  @top
end

#zoomObject

Returns the value of attribute zoom.



3
4
5
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 3

def zoom
  @zoom
end

Instance Method Details

#cloneObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 32

def clone
  camera = Mittsu::OrthographicCamera.new
  super(camera)

  camera.zoom = zoom

  camera.left = left
  camera.right = right
  camera.top = top
  camera.bottom = bottom

  camera.near = near
  camera.far = far

  camera.projection_matrix.copy()

  camera
end

#update_projection_matrixObject



23
24
25
26
27
28
29
30
# File 'lib/mittsu/cameras/orthographic_camera.rb', line 23

def update_projection_matrix
  dx = (right - left) / (2.0 * zoom)
  dy = (top - bottom) / (2.0 * zoom)
  cx = (right + left) / 2.0
  cy = (top + bottom) / 2.0

  projection_matrix.make_orthographic(cx - dx, cx + dx, cy + dy, cy - dy, near, far)
end