I have an app that programatically builds several nodes with morphing meshes. These all work correctly in the scene. When setting .setWeight they all morph as expected. What I would like to do is export these scenes to .scn files so I can load them later. The problem I am having is that when loading these saved .scn files the Geometry Morpher just doesn't work. I see the morph targets there, but when I try to .setWeight nothing happens. I can't figure out why this is happening. This is my export code:
func exportScene() {
let savePanel = NSSavePanel()
savePanel.allowedFileTypes = ["scn"]
savePanel.begin { (result) -> Void in
if result == NSApplication.ModalResponse.OK {
if let sceneFileURL = savePanel.url, let scene = self.sceneView.scene {
let success = scene.write(to: sceneFileURL, options: nil, delegate: nil) { (totalProgress, error, stop) in
print("Progress \(totalProgress) Error: \(String(describing: error))")
}
print("Success: \(success)")
}
} else {
NSSound.beep()
}
}
}
I don't really see a reason that is shouldn't work. If I change the filetype to "dae" and export a Collada file, then re-import those DAEs, the morphs work correctly. But this is unacceptable as I the point is I need all the other elements in the scene (lights, camera, physics objects) as well as the Scenekit specific settings like Tessellation to be saved as well.
The only difference I can see between the saved .scn and .dae is that the .dae, after import, in Geometry Sources show Tangets as Float 4 whereas in the saved .scn file it shows Tangents as Float 3. Any reason this would be? If I delete the Tangents on the morphing mesh in the .scn, save and re-load it the morphs will work, but the rendering is messed up.