Class: Mittsu::Camera

Inherits:
Object3D show all
Defined in:
lib/mittsu/cameras/camera.rb

Direct Known Subclasses

OrthographicCamera, PerspectiveCamera

Constant Summary

Constants inherited from Object3D

Object3D::DefaultUp

Instance Attribute Summary collapse

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 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_position, #get_world_quaternion, #get_world_rotation, #get_world_scale, #init, #init_geometry, #load_uniforms_matrices, #local_to_world, #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

#initializeCamera

Returns a new instance of Camera.



5
6
7
8
9
10
11
# File 'lib/mittsu/cameras/camera.rb', line 5

def initialize
  super

  @type = 'Camera'
  @matrix_world_inverse = Matrix4.new
  @projection_matrix = Matrix4.new
end

Instance Attribute Details

#matrix_world_inverseObject

Returns the value of attribute matrix_world_inverse.



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

def matrix_world_inverse
  @matrix_world_inverse
end

#projection_matrixObject

Returns the value of attribute projection_matrix.



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

def projection_matrix
  @projection_matrix
end

Instance Method Details

#clone(camera = Camera.new) ⇒ Object



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

def clone(camera = Camera.new)
  super
  camera.matrix_world_inverse.copy(@matrix_world_inverse)
  camera.projection_matrix.copy(@projection_matrix)
  camera
end

#get_world_direction(target = Vector3.new) ⇒ Object



13
14
15
16
17
# File 'lib/mittsu/cameras/camera.rb', line 13

def get_world_direction(target = Vector3.new)
  @_quaternion ||= Quaternion.new
  self.get_world_quaternion(@_quaternion)
  target.set(0.0, 0.0, -1.0).apply_quaternion(@_quaternion)
end

#look_at(vector) ⇒ Object



19
20
21
22
23
# File 'lib/mittsu/cameras/camera.rb', line 19

def look_at(vector)
  @_m1 ||= Matrix4.new
  @_m1.look_at(@position, vector, @up)
  @quaternion.set_from_rotation_matrix(@_m1)
end