Loading collada file from webserver in scenekit
Asked Answered
Y

3

5

I am working with SceneKit and Collada file. Now, I am able to load the collada file inside art.scnassets folder as well as in my project root directory. I am getting an error when i am trying to load the file from a local webserver. Any reason why I cannot do this?

let url = NSURL(string: "http://localhost:8888/new.dae")
let scn = try! SCNScene(URL: url!, options: nil)


2016-07-31 17:41:29.537 biOS[3863:254446] SceneKit IO: error, COLLADA files are not supported on this platform.
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=259 "The document "new.dae" could not be opened." UserInfo={NSURL=http://localhost:8888/new.dae, NSLocalizedDescription=The document "new.dae" could not be opened., NSLocalizedRecoverySuggestion=Collada is not supported by this version of SceneKit}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-703.0.18.8/src/swift/stdlib/public/core/ErrorType.swift, line 54

My goal is to read the collada file from a websever and then offer the user to download the file onto the device. I do not know why I am getting the error. By the way, I did a document preview to render the file, and it was successfully about to render document in xml. So, it is not a case of access to the file. Please help!

Yawl answered 31/7, 2016 at 16:48 Comment(0)
N
8

Any reason why I cannot do this?

Yes unfortunately.

During the build process XCode compiles your collada to .scn files. This is a scenekit specific binary file format, doing this reduces the size of the asset files (collada files are XML based) improving the load performance. SceneKit running on an iOS device does not load collada files, only .scn files.

You could look at using ModelIO to load resources that aren't part of your application, but I note collada isn't one of the supported formats.

Nombril answered 1/8, 2016 at 2:3 Comment(0)
F
0

You can also convert your dae files just like Xcode does using terminal. Build a project with Xcode that has a dae and check the commands executed by Xcode (search for scntool) Related: COLLADA transformations in SceneKit

Footrope answered 1/8, 2016 at 17:45 Comment(0)
D
0

I have found the AssetImportKit framework to solve this problem. The framework allows you to import Assimp supported file formats directly in SceneKit at runtime (macOS & iOS). The library supports:

  • Geometry Materials (with color, embedded textures and external textures)
  • Cameras and Skeletal animations
  • Serialization to .scn format
Damnatory answered 30/10, 2019 at 18:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.