Class: Three::DirectionalLight
- Inherits:
-
Light
- Object
- EventDispatcher
- Object3D
- Light
- Three::DirectionalLight
- Defined in:
- lib/three/lights/directional_light.rb
Constant Summary
Constants inherited from Object3D
Object3D::DEFAULT_MATRIX_AUTO_UPDATE, Object3D::DEFAULT_MATRIX_WORLD_AUTO_UPDATE, Object3D::DEFAULT_UP
Instance Attribute Summary collapse
-
#shadow_camera ⇒ Object
readonly
Returns the value of attribute shadow_camera.
Attributes inherited from Light
#color, #intensity, #shadow_bias, #shadow_map_size, #shadow_normal_bias, #shadow_radius
Attributes inherited from Object3D
#cast_shadow, #children, #id, #layers, #matrix, #matrix_auto_update, #matrix_world, #matrix_world_auto_update, #matrix_world_needs_update, #name, #parent, #position, #quaternion, #receive_shadow, #rotation, #scale, #type, #up, #user_data, #uuid, #visible
Instance Method Summary collapse
-
#initialize(color = 0xffffff, intensity = 1) ⇒ DirectionalLight
constructor
A new instance of DirectionalLight.
- #set_shadow_camera(left: nil, right: nil, top: nil, bottom: nil, near: nil, far: nil) ⇒ Object
- #to_h ⇒ Object
Methods inherited from Light
Methods inherited from Object3D
#add, allocate_id, #clear, #dirty_dependency_changed, #get_object_by_id, #get_object_by_name, #get_object_by_property, #get_objects_by_property, #get_world_direction, #get_world_position, #get_world_quaternion, #get_world_scale, #mark_descendant_dirty!, #mark_dirty!, #remove, #remove_from_parent, #to_json, #traverse, #traverse_ancestors, #traverse_visible, #update_matrix, #update_matrix_world, #update_world_matrix
Methods included from Dirty
#add_dirty_dependent, #dirty?, #dirty_dependents, #dirty_field?, #dirty_fields, #mark_clean!, #mark_dirty!, #remove_dirty_dependent
Methods inherited from EventDispatcher
#add_event_listener, #dispatch_event, #has_event_listener?, #remove_event_listener
Constructor Details
#initialize(color = 0xffffff, intensity = 1) ⇒ DirectionalLight
Returns a new instance of DirectionalLight.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/three/lights/directional_light.rb', line 9 def initialize(color = 0xffffff, intensity = 1) super @type = "DirectionalLight" @position.copy(Object3D::DEFAULT_UP) @shadow_camera = { left: -5, right: 5, top: 5, bottom: -5, near: 0.5, far: 500 } end |
Instance Attribute Details
#shadow_camera ⇒ Object (readonly)
Returns the value of attribute shadow_camera.
7 8 9 |
# File 'lib/three/lights/directional_light.rb', line 7 def shadow_camera @shadow_camera end |
Instance Method Details
#set_shadow_camera(left: nil, right: nil, top: nil, bottom: nil, near: nil, far: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/three/lights/directional_light.rb', line 23 def set_shadow_camera(left: nil, right: nil, top: nil, bottom: nil, near: nil, far: nil) @shadow_camera[:left] = left unless left.nil? @shadow_camera[:right] = right unless right.nil? @shadow_camera[:top] = top unless top.nil? @shadow_camera[:bottom] = bottom unless bottom.nil? @shadow_camera[:near] = near unless near.nil? @shadow_camera[:far] = far unless far.nil? mark_dirty!(:shadow) self end |
#to_h ⇒ Object
34 35 36 |
# File 'lib/three/lights/directional_light.rb', line 34 def to_h super.merge(shadow_camera: @shadow_camera.dup) end |