Class: Rgltf::Writer::DefaultOmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/rgltf/writer/default_omitter.rb

Constant Summary collapse

DEFAULTS =
{
  accessor: { 'byteOffset' => 0, 'normalized' => false },
  buffer_view: { 'byteOffset' => 0 },
  primitive: { 'mode' => 4 },
  sampler: { 'wrapS' => 10_497, 'wrapT' => 10_497 },
  texture_info: { 'texCoord' => 0 },
  pbr_metallic_roughness: {
    'baseColorFactor' => [1.0, 1.0, 1.0, 1.0],
    'metallicFactor' => 1.0,
    'roughnessFactor' => 1.0
  },
  material: {
    'emissiveFactor' => [0.0, 0.0, 0.0],
    'alphaMode' => 'OPAQUE',
    'alphaCutoff' => 0.5,
    'doubleSided' => false
  },
  node: {
    'translation' => [0.0, 0.0, 0.0],
    'rotation' => [0.0, 0.0, 0.0, 1.0],
    'scale' => [1.0, 1.0, 1.0]
  },
  animation_sampler: { 'interpolation' => 'LINEAR' }
}.freeze

Class Method Summary collapse

Class Method Details

.apply!(owners, copies) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rgltf/writer/default_omitter.rb', line 31

def self.apply!(owners, copies)
  owners.each do |owner|
    json = copies[owner.source_json.object_id]
    next unless json

    DEFAULTS.fetch(owner.owner_type, {}).each do |key, default|
      json.delete(key) if json[key] == default
    end
    omit_texture_info_defaults!(owner, json)
  end
end