Class: Assimp::Material
- Inherits:
-
Object
- Object
- Assimp::Material
- Defined in:
- lib/assimp/material.rb
Instance Attribute Summary collapse
-
#base_color ⇒ Object
readonly
Returns the value of attribute base_color.
-
#metallic ⇒ Object
readonly
Returns the value of attribute metallic.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#roughness ⇒ Object
readonly
Returns the value of attribute roughness.
-
#shininess ⇒ Object
readonly
Returns the value of attribute shininess.
Instance Method Summary collapse
- #[](key, semantic: 0, index: 0) ⇒ Object
-
#initialize(name:, base_color:, metallic:, roughness:, shininess:, opacity:, two_sided:, textures:, properties:) ⇒ Material
constructor
A new instance of Material.
- #properties ⇒ Object
- #texture(type, index: 0) ⇒ Object
- #textures(type = nil) ⇒ Object
- #two_sided? ⇒ Boolean
Constructor Details
#initialize(name:, base_color:, metallic:, roughness:, shininess:, opacity:, two_sided:, textures:, properties:) ⇒ Material
Returns a new instance of Material.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/assimp/material.rb', line 9 def initialize(name:, base_color:, metallic:, roughness:, shininess:, opacity:, two_sided:, textures:, properties:) @name = String(name).dup.freeze @base_color = base_color&.map { |value| Float(value) }&.freeze @metallic = .nil? ? nil : Float() @roughness = roughness.nil? ? nil : Float(roughness) @shininess = shininess.nil? ? nil : Float(shininess) @opacity = opacity.nil? ? nil : Float(opacity) @two_sided = !!two_sided @textures = textures.freeze @properties = properties.freeze freeze end |
Instance Attribute Details
#base_color ⇒ Object (readonly)
Returns the value of attribute base_color.
7 8 9 |
# File 'lib/assimp/material.rb', line 7 def base_color @base_color end |
#metallic ⇒ Object (readonly)
Returns the value of attribute metallic.
7 8 9 |
# File 'lib/assimp/material.rb', line 7 def @metallic end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/assimp/material.rb', line 7 def name @name end |
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity.
7 8 9 |
# File 'lib/assimp/material.rb', line 7 def opacity @opacity end |
#roughness ⇒ Object (readonly)
Returns the value of attribute roughness.
7 8 9 |
# File 'lib/assimp/material.rb', line 7 def roughness @roughness end |
#shininess ⇒ Object (readonly)
Returns the value of attribute shininess.
7 8 9 |
# File 'lib/assimp/material.rb', line 7 def shininess @shininess end |
Instance Method Details
#[](key, semantic: 0, index: 0) ⇒ Object
49 50 51 |
# File 'lib/assimp/material.rb', line 49 def [](key, semantic: 0, index: 0) @properties[[String(key), Integer(semantic), Integer(index)]] end |
#properties ⇒ Object
53 54 55 |
# File 'lib/assimp/material.rb', line 53 def properties @properties.dup.freeze end |
#texture(type, index: 0) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/assimp/material.rb', line 27 def texture(type, index: 0) kind = type.to_sym texture_index = Integer(index) direct = @textures[[kind, texture_index]] return direct if direct fallback_types(kind).each do |fallback| reference = @textures[[fallback, texture_index]] return reference if reference end nil end |
#textures(type = nil) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/assimp/material.rb', line 40 def textures(type = nil) return @textures.dup.freeze unless type kind = type.to_sym @textures.each_with_object([]) do |((texture_type, _index), texture), matches| matches << texture if texture_type == kind end.freeze end |
#two_sided? ⇒ Boolean
23 24 25 |
# File 'lib/assimp/material.rb', line 23 def two_sided? @two_sided end |