Class: Three::Material
- Inherits:
-
EventDispatcher
- Object
- EventDispatcher
- Three::Material
- Includes:
- Dirty
- Defined in:
- lib/three/materials/material.rb
Direct Known Subclasses
LineBasicMaterial, MeshBasicMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshStandardMaterial, MeshToonMaterial, PointsMaterial, ShadowMaterial, SpriteMaterial
Class Attribute Summary collapse
-
.next_id ⇒ Object
Returns the value of attribute next_id.
Instance Attribute Summary collapse
-
#blending ⇒ Object
Returns the value of attribute blending.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#opacity ⇒ Object
Returns the value of attribute opacity.
-
#side ⇒ Object
Returns the value of attribute side.
-
#transparent ⇒ Object
Returns the value of attribute transparent.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user_data ⇒ Object
Returns the value of attribute user_data.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#vertex_colors ⇒ Object
Returns the value of attribute vertex_colors.
-
#visible ⇒ Object
Returns the value of attribute visible.
Class Method Summary collapse
Instance Method Summary collapse
- #dirty_dependency_changed(_resource, _field) ⇒ Object
- #dispose ⇒ Object
-
#initialize(parameters = nil) ⇒ Material
constructor
A new instance of Material.
- #needs_update ⇒ Object
- #needs_update! ⇒ Object
- #needs_update=(value) ⇒ Object
- #set_values(values) ⇒ Object
- #texture_slots ⇒ Object
- #textures ⇒ Object
- #to_h ⇒ Object
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) ⇒ Material
Returns a new instance of Material.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/three/materials/material.rb', line 22 def initialize(parameters = nil) super() @id = self.class.allocate_id @uuid = MathUtils.generate_uuid @name = "" @type = "Material" @blending = NormalBlending @side = FrontSide @vertex_colors = false @opacity = 1 @transparent = false @visible = true @user_data = {} @needs_update = false set_values(parameters) if parameters mark_dirty! end |
Class Attribute Details
.next_id ⇒ Object
Returns the value of attribute next_id.
15 16 17 |
# File 'lib/three/materials/material.rb', line 15 def next_id @next_id end |
Instance Attribute Details
#blending ⇒ Object
Returns the value of attribute blending.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def blending @blending end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'lib/three/materials/material.rb', line 18 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def name @name end |
#opacity ⇒ Object
Returns the value of attribute opacity.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def opacity @opacity end |
#side ⇒ Object
Returns the value of attribute side.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def side @side end |
#transparent ⇒ Object
Returns the value of attribute transparent.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def transparent @transparent end |
#type ⇒ Object
Returns the value of attribute type.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def type @type end |
#user_data ⇒ Object
Returns the value of attribute user_data.
20 21 22 |
# File 'lib/three/materials/material.rb', line 20 def user_data @user_data end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
18 19 20 |
# File 'lib/three/materials/material.rb', line 18 def uuid @uuid end |
#vertex_colors ⇒ Object
Returns the value of attribute vertex_colors.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def vertex_colors @vertex_colors end |
#visible ⇒ Object
Returns the value of attribute visible.
19 20 21 |
# File 'lib/three/materials/material.rb', line 19 def visible @visible end |
Class Method Details
Instance Method Details
#dirty_dependency_changed(_resource, _field) ⇒ Object
119 120 121 |
# File 'lib/three/materials/material.rb', line 119 def dirty_dependency_changed(_resource, _field) mark_dirty!(:textures) end |
#dispose ⇒ Object
115 116 117 |
# File 'lib/three/materials/material.rb', line 115 def dispose dispatch_event(:dispose) end |
#needs_update ⇒ Object
80 81 82 |
# File 'lib/three/materials/material.rb', line 80 def needs_update @needs_update end |
#needs_update! ⇒ Object
89 90 91 92 |
# File 'lib/three/materials/material.rb', line 89 def needs_update! self.needs_update = true self end |
#needs_update=(value) ⇒ Object
84 85 86 87 |
# File 'lib/three/materials/material.rb', line 84 def needs_update=(value) @needs_update = value mark_dirty!(:parameters) if value end |
#set_values(values) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/three/materials/material.rb', line 100 def set_values(values) values.each do |key, value| setter = "#{key}=" next unless respond_to?(setter) current_value = public_send(key) if respond_to?(key) if current_value.respond_to?(:set) current_value.set(value) else public_send(setter, value) end end self end |
#texture_slots ⇒ Object
123 124 125 |
# File 'lib/three/materials/material.rb', line 123 def texture_slots respond_to?(:map) ? [:map] : [] end |
#textures ⇒ Object
127 128 129 130 131 132 |
# File 'lib/three/materials/material.rb', line 127 def textures texture_slots.each_with_object([]) do |slot, result| texture = public_send(slot) result << texture if texture && !result.include?(texture) end end |
#to_h ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/three/materials/material.rb', line 134 def to_h { uuid: @uuid, type: @type, name: @name, side: @side, opacity: @opacity, transparent: @transparent, visible: @visible, vertex_colors: @vertex_colors } end |