Sha256: 62274ece79e92c456fbb4866dccf23d315cf23b5a5df01711e3558b5530aa529

Contents?: true

Size: 745 Bytes

Versions: 18

Compression:

Stored size: 745 Bytes

Contents

module Mittsu
  class OBJMTLLoader
    include EventDispatcher

    def initialize(manager = DefaultLoadingManager)
      @manager = manager
    end

    def load(url, mtlurl = nil)
      object = OBJLoader.new(@manager).load(url)

      if !mtlurl.nil?
        mtl_loader = MTLLoader.new(File.dirname(url))
        materials_creator = mtl_loader.load(mtlurl)

        materials_creator.preload

        object.traverse do |child_object|
          if child_object.is_a?(Mesh) && child_object.material.name && !child_object.material.name.empty?
            material = materials_creator.create(child_object.material.name)
            child_object.material = material if material
          end
        end
      end

      object
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mittsu-0.5.0 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.4.1 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.4.0 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.3.3 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.3.2 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.3.1 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.3.0 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.2.4 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.2.3 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.2.2 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.2.1 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.2.0 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.1.7 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.1.6 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.1.5 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.1.4 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.1.3 lib/mittsu/loaders/obj_mtl_loader.rb
mittsu-0.1.2 lib/mittsu/loaders/obj_mtl_loader.rb