Skip to content

Commit

Permalink
Merge pull request #3 from Utsira/fix/multipart-models
Browse files Browse the repository at this point in the history
Correctly handle models with multiple textures
  • Loading branch information
Utsira authored Mar 15, 2024
2 parents 37e9ab1 + bf86fe2 commit bf2bd11
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/RealityMorpher/MorphComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ public struct MorphComponent: Component {
var updatedMaterials: [CustomMaterial] = []
let geometryModifier = MorphEnvironment.shared.morphGeometryModifiers[targets.count - 1]

updatedContents.models = try MeshModelCollection(model.mesh.contents.models.enumerated().map { (submodelId, submodel) in
try MeshResource.Model(id: submodel.id, parts: submodel.parts.enumerated().map { (partId, part) in
updatedContents.models = try MeshModelCollection(model.mesh.contents.models.map { submodel in
try MeshResource.Model(id: submodel.id, parts: submodel.parts.map { part in
let material = model.materials[part.materialIndex]

var updatedMaterial = if options.contains(.debugNormals) {
try CustomMaterial(surfaceShader: MorphEnvironment.shared.debugShader, geometryModifier: geometryModifier, lightingModel: .clearcoat)
} else {
try CustomMaterial(from: material, geometryModifier: geometryModifier)
}
let targetParts: [MeshResource.Part] = targets.map {
$0.mesh.contents.models.map { $0 }[submodelId]
.parts.map { $0 }[partId]
let targetParts: [MeshResource.Part] = targets.compactMap {
$0.mesh.contents.models[submodel.id]?
.parts[part.id]
}
let vertCountForPart = part.positions.count
let textureResource = try Self.createTextureForPart(part, targetParts: targetParts, vertCount: vertCountForPart)
Expand Down

0 comments on commit bf2bd11

Please sign in to comment.