Carthage compatible

GLTFSceneKit

SceneKit 的 glTF 加载器

ScreenShot

安装

使用 CocoaPods

将以下内容添加到你的 Podfile

pod 'GLTFSceneKit'

使用 Carthage

将以下内容添加到你的 Cartfile

github "magicien/GLTFSceneKit" ~> 0.4.0

使用 Swift Package Manager

  1. 使用 Xcode 打开你的项目
  2. 选择 File > Swift Packages > Add Package Dependency...
  3. 在搜索框中输入 https://github.com/magicien/GLTFSceneKit 并点击 Next

用法

Swift

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
}

Objective-C

@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;
}

另请参阅

GLTFQuickLook - glTF 文件的 QuickLook 插件