Class: Engine::Components::DirectionLight
- Inherits:
-
Engine::Component
- Object
- Engine::Component
- Engine::Components::DirectionLight
- Includes:
- MatrixHelpers
- Defined in:
- lib/engine/components/direction_light.rb
Instance Attribute Summary collapse
-
#cast_shadows ⇒ Object
Returns the value of attribute cast_shadows.
-
#colour ⇒ Object
Returns the value of attribute colour.
-
#shadow_distance ⇒ Object
Returns the value of attribute shadow_distance.
-
#shadow_layer_index ⇒ Object
Returns the value of attribute shadow_layer_index.
Attributes inherited from Engine::Component
Class Method Summary collapse
Instance Method Summary collapse
Methods included from MatrixHelpers
#look_at, #ortho, #perspective
Methods inherited from Engine::Component
#_erase!, #destroy, #destroyed?, destroyed_components, erase_destroyed_components, method_added, #renderer?, #set_game_object, #ui_renderer?, #update
Methods included from Serializable
allowed_class?, get_class, included, register_class, #uuid
Instance Attribute Details
#cast_shadows ⇒ Object
Returns the value of attribute cast_shadows.
9 10 11 |
# File 'lib/engine/components/direction_light.rb', line 9 def cast_shadows @cast_shadows end |
#colour ⇒ Object
Returns the value of attribute colour.
9 10 11 |
# File 'lib/engine/components/direction_light.rb', line 9 def colour @colour end |
#shadow_distance ⇒ Object
Returns the value of attribute shadow_distance.
9 10 11 |
# File 'lib/engine/components/direction_light.rb', line 9 def shadow_distance @shadow_distance end |
#shadow_layer_index ⇒ Object
Returns the value of attribute shadow_layer_index.
10 11 12 |
# File 'lib/engine/components/direction_light.rb', line 10 def shadow_layer_index @shadow_layer_index end |
Class Method Details
.direction_lights ⇒ Object
57 58 59 |
# File 'lib/engine/components/direction_light.rb', line 57 def self.direction_lights @direction_lights ||= [] end |
Instance Method Details
#awake ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/engine/components/direction_light.rb', line 12 def awake @colour ||= [1.0, 1.0, 1.0] @cast_shadows = true if @cast_shadows.nil? @shadow_distance ||= 50.0 @shadow_layer_index = nil @cached_light_space_matrix = nil @cache_key = nil end |
#destroy! ⇒ Object
39 40 41 |
# File 'lib/engine/components/direction_light.rb', line 39 def destroy! DirectionLight.direction_lights.delete(self) end |
#direction ⇒ Object
43 44 45 |
# File 'lib/engine/components/direction_light.rb', line 43 def direction game_object.forward.normalize end |
#light_space_matrix ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/engine/components/direction_light.rb', line 47 def light_space_matrix current_key = compute_cache_key if @cached_light_space_matrix && @cache_key == current_key return @cached_light_space_matrix end @cache_key = current_key @cached_light_space_matrix = compute_light_space_matrix end |
#start ⇒ Object
35 36 37 |
# File 'lib/engine/components/direction_light.rb', line 35 def start DirectionLight.direction_lights << self end |