Although documented the following MDLAsset
class methods do not exist in the ModelIO
library:
+ assetWithSCNScene:bufferAllocator:
+ assetWithSCNScene:
So, currently there is no way to read in a SceneKit
.scn file and create an MDLAsset
.
What is the work around?
I am importing these:
import SceneKit
import ModelIO
import MetalKit
import GLKit
In my renderer I attempt to instantiate an MDLAsset
from an SCNScene
:
guard let scene = SCNScene(named:"ball.scn") else {
fatalError("Error: Can not create scene")
}
let asset = MDLAsset(scnScene:scene, bufferAllocator:MTKMeshBufferAllocator(device: device))
I get this error
Indicating the category cannot be found. What have I missed here?
These are defined as a category on MDLAsset
by SceneKit (which is necessary, because that's where SCNScene
is defined). You need to @import SceneKit
as well as @import ModelIO
.
You'd listed the signatures in ObjC; didn't note that you'd tagged it Swift. In Swift, you need to import the relevant submodule:
import SceneKit.ModelIO
That's actually a bit strange IMO, and probably shouldn't be necessary. I'd open a radar (bugreport.apple.com). At the very least, the docs need to be clearer.