remove materail index
This commit is contained in:
parent
94d33b1cfe
commit
c7ab788ae1
|
@ -14,9 +14,9 @@ extension GLTF {
|
|||
// MARK: - Material
|
||||
|
||||
// load material by index
|
||||
internal func loadMaterial(index:Int, delegate: TextureLoaderDelegate, textureChangedCallback: ((Any?)-> Void)? = nil, completionHandler: @escaping (SCNMaterial) -> Void) {
|
||||
internal func loadMaterial(_ material:GLTFMaterial?, delegate: TextureLoaderDelegate, textureChangedCallback: ((Any?)-> Void)? = nil, completionHandler: @escaping (SCNMaterial) -> Void) {
|
||||
|
||||
if let material = self.materials?[index] {
|
||||
if let material = material {
|
||||
let scnMaterial = SCNMaterial()
|
||||
scnMaterial.name = material.name
|
||||
scnMaterial.isDoubleSided = material.doubleSided
|
||||
|
|
|
@ -80,7 +80,7 @@ open class GLTFMeshPrimitive : NSObject, Codable {
|
|||
public var indices:Int?
|
||||
|
||||
/// The index of the material to apply to this primitive when rendering.
|
||||
public var material:Int?
|
||||
public var material:GLTFMaterial?
|
||||
|
||||
/// The type of primitives to render.
|
||||
public var mode:GLTFMeshPrimitiveMode
|
||||
|
@ -109,7 +109,7 @@ open class GLTFMeshPrimitive : NSObject, Codable {
|
|||
extensions = try? container.decode([String: GLTFKHRDracoMeshCompressionExtension].self, forKey: .extensions)
|
||||
extras = try? container.decode([String: Any].self, forKey: .extras)
|
||||
indices = try? container.decode(Int.self, forKey: .indices)
|
||||
material = try? container.decode(Int.self, forKey: .material)
|
||||
material = try? container.decode(GLTFMaterial.self, forKey: .material)
|
||||
do {
|
||||
mode = try container.decode(GLTFMeshPrimitiveMode.self, forKey: .mode)
|
||||
} catch {
|
||||
|
|
|
@ -209,8 +209,8 @@ extension GLTFConverter {
|
|||
primitiveNode.geometry!.firstMaterial = emptyMaterial
|
||||
}
|
||||
|
||||
if let materialIndex = primitive.material {
|
||||
self.glTF.loadMaterial(index:materialIndex, delegate: self, textureChangedCallback: { _ in
|
||||
if let material = primitive.material {
|
||||
self.glTF.loadMaterial(material, delegate: self, textureChangedCallback: { _ in
|
||||
if let material = primitiveNode.geometry?.firstMaterial {
|
||||
if let texture = material.diffuse.contents as? MTLTexture {
|
||||
if texture.pixelFormat.hasAlpha() {
|
||||
|
|
Loading…
Reference in New Issue