Class: Three::MeshPhongMaterial
- Inherits:
-
Material
- Object
- EventDispatcher
- Material
- Three::MeshPhongMaterial
- Defined in:
- lib/three/materials/mesh_phong_material.rb
Constant Summary collapse
- TEXTURE_SLOTS =
%i[ map alpha_map ao_map bump_map displacement_map emissive_map env_map light_map normal_map specular_map ].freeze
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#emissive ⇒ Object
Returns the value of attribute emissive.
-
#flat_shading ⇒ Object
Returns the value of attribute flat_shading.
-
#fog ⇒ Object
Returns the value of attribute fog.
-
#shininess ⇒ Object
Returns the value of attribute shininess.
-
#specular ⇒ Object
Returns the value of attribute specular.
-
#wireframe ⇒ Object
Returns the value of attribute wireframe.
-
#wireframe_linewidth ⇒ Object
Returns the value of attribute wireframe_linewidth.
Attributes inherited from Material
#blending, #id, #name, #opacity, #side, #transparent, #type, #user_data, #uuid, #vertex_colors, #visible
Instance Method Summary collapse
-
#initialize(parameters = nil) ⇒ MeshPhongMaterial
constructor
A new instance of MeshPhongMaterial.
- #texture_slots ⇒ Object
- #to_h ⇒ Object
Methods inherited from Material
allocate_id, #dirty_dependency_changed, #dispose, #needs_update, #needs_update!, #needs_update=, #set_values, #textures
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(parameters = nil) ⇒ MeshPhongMaterial
Returns a new instance of MeshPhongMaterial.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/three/materials/mesh_phong_material.rb', line 24 def initialize(parameters = nil) super(nil) @type = "MeshPhongMaterial" @color = Color.new(0xffffff) @specular = Color.new(0x111111) @emissive = Color.new(0x000000) @shininess = 30 TEXTURE_SLOTS.each { |slot| instance_variable_set(:"@#{slot}", nil) } @wireframe = false @wireframe_linewidth = 1 @fog = true @flat_shading = false bind_color_changes set_values(parameters) if parameters mark_dirty! end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def color @color end |
#emissive ⇒ Object
Returns the value of attribute emissive.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def emissive @emissive end |
#flat_shading ⇒ Object
Returns the value of attribute flat_shading.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def flat_shading @flat_shading end |
#fog ⇒ Object
Returns the value of attribute fog.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def fog @fog end |
#shininess ⇒ Object
Returns the value of attribute shininess.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def shininess @shininess end |
#specular ⇒ Object
Returns the value of attribute specular.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def specular @specular end |
#wireframe ⇒ Object
Returns the value of attribute wireframe.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def wireframe @wireframe end |
#wireframe_linewidth ⇒ Object
Returns the value of attribute wireframe_linewidth.
21 22 23 |
# File 'lib/three/materials/mesh_phong_material.rb', line 21 def wireframe_linewidth @wireframe_linewidth end |
Instance Method Details
#texture_slots ⇒ Object
88 89 90 |
# File 'lib/three/materials/mesh_phong_material.rb', line 88 def texture_slots TEXTURE_SLOTS end |
#to_h ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/three/materials/mesh_phong_material.rb', line 92 def to_h result = super.merge( color: @color.hex, specular: @specular.hex, emissive: @emissive.hex, shininess: @shininess, wireframe: @wireframe, wireframe_linewidth: @wireframe_linewidth, fog: @fog, flat_shading: @flat_shading ) TEXTURE_SLOTS.each { |slot| result[slot] = public_send(slot)&.to_h } result end |