Class: Mittsu::HemisphereLight

Inherits:
Light show all
Defined in:
lib/mittsu/lights/hemisphere_light.rb,
lib/mittsu/renderers/opengl/lights/hemisphere_light.rb

Defined Under Namespace

Classes: Cache

Constant Summary collapse

TYPE =
:hemi

Constants inherited from Object3D

Object3D::DefaultUp

Instance Attribute Summary collapse

Attributes inherited from Light

#camera_helper, #color, #distance, #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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Light

#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(sky_color = nil, ground_color = nil, intensity = 1.0) ⇒ HemisphereLight

Returns a new instance of HemisphereLight.



8
9
10
11
12
13
14
15
16
17
# File 'lib/mittsu/lights/hemisphere_light.rb', line 8

def initialize(sky_color = nil, ground_color = nil, intensity = 1.0)
  super(sky_color)

  @type = 'HemisphereLight'

  @position.set(0.0, 100.0, 0.0)

  @ground_color = Color.new(ground_color)
  @intensity = intensity
end

Instance Attribute Details

#ground_colorObject

Returns the value of attribute ground_color.



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

def ground_color
  @ground_color
end

#intensityObject

Returns the value of attribute intensity.



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

def intensity
  @intensity
end

Class Method Details

.null_remaining_lights(cache) ⇒ Object



30
31
32
33
# File 'lib/mittsu/renderers/opengl/lights/hemisphere_light.rb', line 30

def self.null_remaining_lights(cache)
  super(cache, cache.ground_colors)
  super(cache, cache.sky_colors)
end

Instance Method Details

#cloneObject



19
20
21
22
23
24
25
26
27
# File 'lib/mittsu/lights/hemisphere_light.rb', line 19

def clone
  light = HemisphereLight.new
  super(light)

  light.ground_color.copy(@ground_color)
  light.intensity = @intensity

  light
end

#setup_specific(index) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mittsu/renderers/opengl/lights/hemisphere_light.rb', line 15

def setup_specific(index)
  offset = index * 3

  @_direction.set_from_matrix_position(matrix_world)
  @_direction.normalize

  positions = @cache.positions
  positions[offset]     = @_direction.x
  positions[offset + 1] = @_direction.y
  positions[offset + 2] = @_direction.z

  OpenGLHelper.set_color_linear(@cache.sky_colors, offset, color, intensity)
  OpenGLHelper.set_color_linear(@cache.ground_colors, offset, ground_color, intensity)
end

#to_symObject



35
36
37
# File 'lib/mittsu/renderers/opengl/lights/hemisphere_light.rb', line 35

def to_sym
  :hemi
end