GLTFSceneKit

repository·master·Indexed 43 days ago

https://github.com/magicien/gltfscenekit

A glTF loader for Apple's SceneKit framework that allows developers to import glTF assets into SCNScene objects for use on iOS, macOS, and other Apple platforms. Supports installation via CocoaPods, Carthage, and Swift Package Manager.

Tokens
444
Snippets
4
Records
5
Agent score
6%

What's inside GLTFSceneKit

  1. Install GLTFSceneKit via Swift Package Manager

    master

    To install using Swift Package Manager (SPM):

    1. Open your project in Xcode.
    2. Select File > Swift Packages > Add Package Dependency....
    3. Enter https://github.com/magicien/GLTFSceneKit in the search box and click Next.
  2. Load a glTF scene in Swift

    master

    Use GLTFSceneSource to load a glTF file from your project assets and convert it into an SCNScene.

    import GLTFSceneKit
    
    var scene: SCNScene
    do {
      let sceneSource = try GLTFSceneSource(named: "art.scnassets/Box/glTF/Box.gltf")
      scene = try sceneSource.scene()
    } catch {
      print("\(error.localizedDescription)")
      return
    }
  3. Load a glTF scene in Objective-C

    master

    Use GLTFSceneSource with initWithURL:options: to initialize a source from a URL, then call sceneWithOptions:error: to generate the SCNScene.

    @import GLTFSceneKit;
    
    GLTFSceneSource *source = [[GLTFSceneSource alloc] initWithURL:url options:nil];
    NSError *error;
    SCNScene *scene = [source sceneWithOptions:nil error:&error];
    if (error != nil) {
      NSLog("@%@", error);
      return;
    }