Class: Engine::Components::PointLight
Constant Summary
collapse
- NR_SHADOW_CASTING_POINT_LIGHTS =
4
- CUBE_DIRECTIONS =
Cubemap face directions: X, -X, Y, -Y, +Z, -Z
[
{ dir: Vector[1, 0, 0], up: Vector[0, -1, 0] },
{ dir: Vector[-1, 0, 0], up: Vector[0, -1, 0] },
{ dir: Vector[0, 1, 0], up: Vector[0, 0, 1] },
{ dir: Vector[0, -1, 0], up: Vector[0, 0, -1] },
{ dir: Vector[0, 0, 1], up: Vector[0, -1, 0] },
{ dir: Vector[0, 0, -1], up: Vector[0, -1, 0] }
].freeze
Instance Attribute Summary collapse
#game_object
Class Method Summary
collapse
Instance Method Summary
collapse
#look_at, #ortho, #perspective
#_erase!, #destroy, #destroyed?, destroyed_components, erase_destroyed_components, method_added, #renderer?, #set_game_object, #ui_renderer?
allowed_class?, get_class, included, register_class, #uuid
Instance Attribute Details
#cast_shadows ⇒ Object
Returns the value of attribute cast_shadows.
21
22
23
|
# File 'lib/engine/components/point_light.rb', line 21
def cast_shadows
@cast_shadows
end
|
#colour ⇒ Object
Returns the value of attribute colour.
21
22
23
|
# File 'lib/engine/components/point_light.rb', line 21
def colour
@colour
end
|
#range ⇒ Object
Returns the value of attribute range.
21
22
23
|
# File 'lib/engine/components/point_light.rb', line 21
def range
@range
end
|
#shadow_layer_index ⇒ Object
Returns the value of attribute shadow_layer_index.
21
22
23
|
# File 'lib/engine/components/point_light.rb', line 21
def shadow_layer_index
@shadow_layer_index
end
|
Class Method Details
.point_lights ⇒ Object
59
60
61
|
# File 'lib/engine/components/point_light.rb', line 59
def self.point_lights
@point_lights ||= []
end
|
.shadow_casting_lights ⇒ Object
63
64
65
|
# File 'lib/engine/components/point_light.rb', line 63
def self.shadow_casting_lights
point_lights.select(&:cast_shadows).take(NR_SHADOW_CASTING_POINT_LIGHTS)
end
|
Instance Method Details
#awake ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/engine/components/point_light.rb', line 23
def awake
@range ||= 300
@colour ||= [1.0, 1.0, 1.0]
@cast_shadows = false if @cast_shadows.nil?
@shadow_layer_index = nil
@cached_light_space_matrices = nil
end
|
#destroy! ⇒ Object
35
36
37
|
# File 'lib/engine/components/point_light.rb', line 35
def destroy!
PointLight.point_lights.delete(self)
end
|
#light_space_matrices ⇒ Object
55
56
57
|
# File 'lib/engine/components/point_light.rb', line 55
def light_space_matrices
@cached_light_space_matrices ||= compute_light_space_matrices
end
|
#position ⇒ Object
43
44
45
|
# File 'lib/engine/components/point_light.rb', line 43
def position
game_object.local_to_world_coordinate(Vector[0, 0, 0])
end
|
#shadow_far ⇒ Object
51
52
53
|
# File 'lib/engine/components/point_light.rb', line 51
def shadow_far
@range * 2.0
end
|
#shadow_near ⇒ Object
47
48
49
|
# File 'lib/engine/components/point_light.rb', line 47
def shadow_near
@range * 0.01
end
|
#start ⇒ Object
31
32
33
|
# File 'lib/engine/components/point_light.rb', line 31
def start
PointLight.point_lights << self
end
|
#update(delta_time) ⇒ Object
39
40
41
|
# File 'lib/engine/components/point_light.rb', line 39
def update(delta_time)
@cached_light_space_matrices = nil if @cast_shadows
end
|