Class: Mittsu::MeshFaceMaterial

Inherits:
Object
  • Object
show all
Defined in:
lib/mittsu/materials/mesh_face_material.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(materials = []) ⇒ MeshFaceMaterial

Returns a new instance of MeshFaceMaterial.



7
8
9
10
11
# File 'lib/mittsu/materials/mesh_face_material.rb', line 7

def initialize(materials = [])
  @uuid = SecureRandom.uuid
  @type = 'MeshFaceMaterial'
  @materials = materials
end

Instance Attribute Details

#materialsObject (readonly)

Returns the value of attribute materials.



5
6
7
# File 'lib/mittsu/materials/mesh_face_material.rb', line 5

def materials
  @materials
end

Instance Method Details

#cloneObject



26
27
28
29
30
# File 'lib/mittsu/materials/mesh_face_material.rb', line 26

def clone
  MeshFaceMaterial.new.tap do |mateiral|
    material.materials = @materials.map(&:clone)
  end
end

#to_jsonObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mittsu/materials/mesh_face_material.rb', line 13

def to_json
  {
    metadata: {
      version: 4.2,
      type: 'material',
      generator: 'MaterialExporter'
    },
    uuid: @uuid,
    type: @type,
    materials: @materials.map(&:to_json)
  }
end