Class: Three::MeshStandardMaterial

Inherits:
Material show all
Defined in:
lib/three/materials/mesh_standard_material.rb

Direct Known Subclasses

MeshPhysicalMaterial

Constant Summary collapse

TEXTURE_SLOTS =
%i[
  map
  alpha_map
  ao_map
  bump_map
  displacement_map
  emissive_map
  env_map
  light_map
  metalness_map
  normal_map
  roughness_map
].freeze

Instance Attribute Summary collapse

Attributes inherited from Material

#blending, #id, #name, #opacity, #side, #transparent, #type, #user_data, #uuid, #vertex_colors, #visible

Instance Method Summary collapse

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) ⇒ MeshStandardMaterial

Returns a new instance of MeshStandardMaterial.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/three/materials/mesh_standard_material.rb', line 25

def initialize(parameters = nil)
  super(nil)
  @type = "MeshStandardMaterial"
  @color = Color.new(0xffffff)
  @roughness = 1
  @metalness = 0
  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

#colorObject

Returns the value of attribute color.



22
23
24
# File 'lib/three/materials/mesh_standard_material.rb', line 22

def color
  @color
end

#flat_shadingObject

Returns the value of attribute flat_shading.



22
23
24
# File 'lib/three/materials/mesh_standard_material.rb', line 22

def flat_shading
  @flat_shading
end

#fogObject

Returns the value of attribute fog.



22
23
24
# File 'lib/three/materials/mesh_standard_material.rb', line 22

def fog
  @fog
end

#metalnessObject

Returns the value of attribute metalness.



22
23
24
# File 'lib/three/materials/mesh_standard_material.rb', line 22

def metalness
  @metalness
end

#roughnessObject

Returns the value of attribute roughness.



22
23
24
# File 'lib/three/materials/mesh_standard_material.rb', line 22

def roughness
  @roughness
end

#wireframeObject

Returns the value of attribute wireframe.



22
23
24
# File 'lib/three/materials/mesh_standard_material.rb', line 22

def wireframe
  @wireframe
end

#wireframe_linewidthObject

Returns the value of attribute wireframe_linewidth.



22
23
24
# File 'lib/three/materials/mesh_standard_material.rb', line 22

def wireframe_linewidth
  @wireframe_linewidth
end

Instance Method Details

#alpha_map=(value) ⇒ Object



61
62
63
# File 'lib/three/materials/mesh_standard_material.rb', line 61

def alpha_map=(value)
  set_texture_slot(:alpha_map, value)
end

#ao_map=(value) ⇒ Object



65
66
67
# File 'lib/three/materials/mesh_standard_material.rb', line 65

def ao_map=(value)
  set_texture_slot(:ao_map, value)
end

#bump_map=(value) ⇒ Object



69
70
71
# File 'lib/three/materials/mesh_standard_material.rb', line 69

def bump_map=(value)
  set_texture_slot(:bump_map, value)
end

#displacement_map=(value) ⇒ Object



73
74
75
# File 'lib/three/materials/mesh_standard_material.rb', line 73

def displacement_map=(value)
  set_texture_slot(:displacement_map, value)
end

#emissive_map=(value) ⇒ Object



77
78
79
# File 'lib/three/materials/mesh_standard_material.rb', line 77

def emissive_map=(value)
  set_texture_slot(:emissive_map, value)
end

#env_map=(value) ⇒ Object



81
82
83
# File 'lib/three/materials/mesh_standard_material.rb', line 81

def env_map=(value)
  set_texture_slot(:env_map, value)
end

#light_map=(value) ⇒ Object



85
86
87
# File 'lib/three/materials/mesh_standard_material.rb', line 85

def light_map=(value)
  set_texture_slot(:light_map, value)
end

#map=(value) ⇒ Object



57
58
59
# File 'lib/three/materials/mesh_standard_material.rb', line 57

def map=(value)
  set_texture_slot(:map, value)
end

#metalness_map=(value) ⇒ Object



89
90
91
# File 'lib/three/materials/mesh_standard_material.rb', line 89

def metalness_map=(value)
  set_texture_slot(:metalness_map, value)
end

#normal_map=(value) ⇒ Object



93
94
95
# File 'lib/three/materials/mesh_standard_material.rb', line 93

def normal_map=(value)
  set_texture_slot(:normal_map, value)
end

#roughness_map=(value) ⇒ Object



97
98
99
# File 'lib/three/materials/mesh_standard_material.rb', line 97

def roughness_map=(value)
  set_texture_slot(:roughness_map, value)
end

#texture_slotsObject



121
122
123
# File 'lib/three/materials/mesh_standard_material.rb', line 121

def texture_slots
  TEXTURE_SLOTS
end

#to_hObject



125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/three/materials/mesh_standard_material.rb', line 125

def to_h
  result = super.merge(
    color: @color.hex,
    roughness: @roughness,
    metalness: @metalness,
    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