Class: Mittsu::PointLight
- Defined in:
- lib/mittsu/lights/point_light.rb,
lib/mittsu/renderers/opengl/lights/point_light.rb
Defined Under Namespace
Classes: Cache
Constant Summary collapse
- TYPE =
:point
Constants inherited from Object3D
Instance Attribute Summary collapse
-
#decay ⇒ Object
Returns the value of attribute decay.
Attributes inherited from Light
#camera_helper, #color, #distance, #intensity, #only_shadow
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
- #clone ⇒ Object
-
#initialize(color = nil, intensity = 1.0, distance = 0.0, decay = 1.0) ⇒ PointLight
constructor
A new instance of PointLight.
- #setup_specific(index) ⇒ Object
- #to_sym ⇒ Object
Methods inherited from Light
null_remaining_lights, #project, #setup, #type
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(color = nil, intensity = 1.0, distance = 0.0, decay = 1.0) ⇒ PointLight
Returns a new instance of PointLight.
7 8 9 10 11 12 13 14 15 |
# File 'lib/mittsu/lights/point_light.rb', line 7 def initialize(color = nil, intensity = 1.0, distance = 0.0, decay = 1.0) super(color) @type = 'PointLight' @intensity = intensity @distance = distance @decay = decay # for physically correct light, should be 2 end |
Instance Attribute Details
#decay ⇒ Object
Returns the value of attribute decay.
5 6 7 |
# File 'lib/mittsu/lights/point_light.rb', line 5 def decay @decay end |
Instance Method Details
#clone ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mittsu/lights/point_light.rb', line 17 def clone light = PointLight.new super(light) light.intensity = @intensity light.distance = @distance light.decay = @decay light end |
#setup_specific(index) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mittsu/renderers/opengl/lights/point_light.rb', line 15 def setup_specific(index) offset = index * 3; OpenGLHelper.set_color_linear(@cache.colors, offset, color, intensity) @_vector3.set_from_matrix_position(matrix_world) positions = @cache.positions positions[offset] = @_vector3.x positions[offset + 1] = @_vector3.y positions[offset + 2] = @_vector3.z # distance is 0 if decay is 0, because there is no attenuation at all. @cache.distances[index] = distance @cache.decays[index] = distance.zero? ? 0.0 : decay end |
#to_sym ⇒ Object
32 33 34 |
# File 'lib/mittsu/renderers/opengl/lights/point_light.rb', line 32 def to_sym :point end |