class Mittsu::Material
Attributes
alpha_map[RW]
alpha_test[RW]
attributes[RW]
blend_dst[RW]
blend_dst_alpha[RW]
blend_equation[RW]
blend_equation_alpha[RW]
blend_src[RW]
blend_src_alpha[RW]
blending[RW]
bump_map[RW]
color[RW]
color_write[RW]
combine[RW]
default_attribute_values[RW]
defines[RW]
depth_test[RW]
depth_write[RW]
env_map[RW]
fog[RW]
fragment_shader[RW]
id[R]
light_map[RW]
lights[RW]
map[RW]
metal[RW]
morph_normals[RW]
morph_targets[RW]
name[RW]
normal_map[RW]
opacity[RW]
overdraw[RW]
polygon_offset[RW]
polygon_offset_factor[RW]
polygon_offset_units[RW]
program[RW]
reflectivity[RW]
refraction_ratio[RW]
shading[RW]
side[RW]
size_attenuation[RW]
skinning[RW]
specular_map[RW]
transparent[RW]
type[R]
uniforms[RW]
uuid[R]
vertex_colors[RW]
vertex_shader[RW]
visible[RW]
wireframe[RW]
wrap_around[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/mittsu/materials/material.rb, line 17 def initialize super @id = (@@id ||= 1).tap { @@id += 1 } @uuid = SecureRandom.uuid @name = '' @type = 'Material' @side = FrontSide @opacity = 1.0 @transparent = false @blending = NormalBlending @blend_src = SrcAlphaFactor @blend_dst = OneMinusSrcAlphaFactor @blend_equation = AddEquation @blend_src_alpha = nil @blend_dst_alpha = nil @blend_equation_alpha = nil @depth_test = true @depth_write = true @color_write = true @polygon_offset = false @polygon_offset_factor = 0 @polygon_offset_units = 0 @alpha_test = 0 # TODO: remove this maybe??? @overdraw = 0 # Overdrawn pixels (typically between 0 and 1) for fixing antialiasing gaps in CanvasRenderer @visible = true @_needs_update = true end
Public Instance Methods
clone(material = Material.new)
click to toggle source
# File lib/mittsu/materials/material.rb, line 110 def clone(material = Material.new) material.name = @name material.side = @side material.opacity = @opacity material.transparent = @transparent material.blending = @blending material.blend_src = @blend_src material.blend_dst = @blend_dst material.blend_equation = @blend_equation material.blend_src_alpha = @blend_src_alpha material.blend_dst_alpha = @blend_dst_alpha material.blend_equation_alpha = @blend_equation_alpha material.depth_test = @depth_test material.depth_write = @depth_write material.color_write = @color_write material.polygon_offset = @polygon_offset material.polygon_offset_factor = @polygon_offset_factor material.polygon_offset_units = @polygon_offset_units material.alpha_test = @alpha_test material.overdraw = @overdraw material.visible = @visible end
dispose()
click to toggle source
# File lib/mittsu/materials/material.rb, line 137 def dispose dispatch_event type: :dispose end
needs_update=(value)
click to toggle source
# File lib/mittsu/materials/material.rb, line 63 def needs_update=(value) update if value @_needs_update = value end
needs_update?()
click to toggle source
# File lib/mittsu/materials/material.rb, line 59 def needs_update? @_needs_update end
set_values(values = nil)
click to toggle source
# File lib/mittsu/materials/material.rb, line 68 def set_values(values = nil) return if values.nil? values.each do |(key, new_value)| if new_value.nil? puts "WARNING: Mittsu::Material: #{key} parameter is undefined" next end if has_property? key current_value = get_property(key) if current_value.is_a? Color current_value.set(new_value) elsif current_value.is_a?(Vector3) && new_value.is_a?(Vector3) current_value.copy(new_value) else set_property(key, new_value) end end end end
to_json()
click to toggle source
# File lib/mittsu/materials/material.rb, line 91 def to_json output = { metadata: { version: 4.2, type: 'material', generator: 'MaterialExporter' }, uuid: @uuid, type: @type } output[:name] = @name if !@name.nil? && !@name.empty? output[:opacity] = @opacity if @opacity < 1.0 output[:transparent] = @transparent if @transparent output[:wireframe] = @wireframe if @wireframe output end
update()
click to toggle source
# File lib/mittsu/materials/material.rb, line 133 def update dispatch_event type: :update end
Private Instance Methods
get_property(key)
click to toggle source
# File lib/mittsu/materials/material.rb, line 153 def get_property(key) sym = "@#{key}".to_sym self.instance_variable_get(sym) end
has_property?(key)
click to toggle source
# File lib/mittsu/materials/material.rb, line 143 def has_property?(key) sym = "@#{key}".to_sym self.instance_variable_defined?(sym) end
set_property(key, value)
click to toggle source
# File lib/mittsu/materials/material.rb, line 148 def set_property(key, value) sym = "@#{key}".to_sym self.instance_variable_set(sym, value) end