Class: Mittsu::Light

Inherits:
Object3D show all
Defined in:
lib/mittsu/lights/light.rb,
lib/mittsu/renderers/opengl/lights/light.rb

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, #up, #user_data, #uuid, #visible

Class Method Summary collapse

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_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, #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(color = nil) ⇒ Light

Returns a new instance of Light.



8
9
10
11
12
# File 'lib/mittsu/lights/light.rb', line 8

def initialize(color = nil)
  super()
  @type = 'Light'
  @color = Color.new(color)
end

Instance Attribute Details

#camera_helperObject

Returns the value of attribute camera_helper.



3
4
5
# File 'lib/mittsu/renderers/opengl/lights/light.rb', line 3

def camera_helper
  @camera_helper
end

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/mittsu/lights/light.rb', line 6

def color
  @color
end

#distanceObject

Returns the value of attribute distance.



6
7
8
# File 'lib/mittsu/lights/light.rb', line 6

def distance
  @distance
end

#intensityObject

Returns the value of attribute intensity.



6
7
8
# File 'lib/mittsu/lights/light.rb', line 6

def intensity
  @intensity
end

#only_shadowObject

Returns the value of attribute only_shadow.



6
7
8
# File 'lib/mittsu/lights/light.rb', line 6

def only_shadow
  @only_shadow
end

Class Method Details

.null_remaining_lights(cache, colors = nil) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/mittsu/renderers/opengl/lights/light.rb', line 43

def self.null_remaining_lights(cache, colors = nil)
  colors ||= cache.colors
  count = [colors.length, cache.count * 3].max
  (cache.length * 3).upto(count - 1).each { |i|
    colors[i] = 0.0
  }
end

Instance Method Details

#clone(light = Light.new) ⇒ Object



14
15
16
17
18
19
# File 'lib/mittsu/lights/light.rb', line 14

def clone(light = Light.new)
  super(light)

  light.color.copy(@color)
  light
end

#project(renderer) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/mittsu/renderers/opengl/lights/light.rb', line 34

def project(renderer)
  @renderer = renderer
  return unless visible
  init
  # TODO!!! FIXME!!!
  @renderer.instance_variable_get(:@lights) << self
  project_children
end

#setup(light_renderer) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mittsu/renderers/opengl/lights/light.rb', line 19

def setup(light_renderer)
  @light_renderer = light_renderer
  @cache ||= @light_renderer.cache[type]
  @cache.count += 1

  return unless visible

  @_direction ||= Vector3.new
  @_vector3 ||= Vector3.new

  setup_specific(@cache.length)

  @cache.length += 1
end

#to_symObject



51
52
53
# File 'lib/mittsu/renderers/opengl/lights/light.rb', line 51

def to_sym
  :other
end

#typeObject

def initialize(light, renderer)

super
@light = light
@light_renderer = renderer.light_renderer

@_direction = Vector3.new
@_vector3 = Vector3.new

end



15
16
17
# File 'lib/mittsu/renderers/opengl/lights/light.rb', line 15

def type
  self.class::TYPE
end