Skip to content

Commit

Permalink
Add test for watchOS, which can import SceneKit, but has no SCNScene …
Browse files Browse the repository at this point in the history
…write method.
  • Loading branch information
deirdresm authored and nicklockwood committed Mar 31, 2024
1 parent b769e29 commit 850b1b3
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions Sources/Mesh+IO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,26 @@ public extension Mesh {
try string.write(to: url, atomically: true, encoding: .utf8)
#endif
default:
#if canImport(SceneKit)
let scnScene = SCNScene()
let materialLookup = materialLookup.map { lookup in { defaultMaterialLookup(lookup($0)) } }
let geometry = SCNGeometry(polygons: self, materialLookup: materialLookup)
scnScene.rootNode.addChildNode(SCNNode(geometry: geometry))
guard scnScene.write(
to: url,
options: [:],
delegate: nil,
progressHandler: nil
) else {
throw IOError("Failed to export file")
}
#else
throw IOError("Unsupported mesh file format '\(url.pathExtension)'")
#endif
#if os(watchOS)
throw IOError("Cannot export '\(url.pathExtension)' on watchOS.")
#else
#if canImport(SceneKit)
let scnScene = SCNScene()
let materialLookup = materialLookup.map { lookup in { defaultMaterialLookup(lookup($0)) } }
let geometry = SCNGeometry(polygons: self, materialLookup: materialLookup)
scnScene.rootNode.addChildNode(SCNNode(geometry: geometry))
guard scnScene.write(
to: url,
options: [:],
delegate: nil,
progressHandler: nil
) else {
throw IOError("Failed to export file")
}
#else
throw IOError("Unsupported mesh file format '\(url.pathExtension)'")
#endif
#endif
}
}
}
Expand Down

0 comments on commit 850b1b3

Please sign in to comment.