Poly
是一个非官方的 Google Poly SDK,用 Swift 编写。
这个库可以轻松地与 Google Poly 集成,并提供一些额外的客户端功能。
功能特性 | |
---|---|
🔍 | 3D 模型搜索 |
⬇ | 3D 模型下载管理 |
📦 | 高级 3D 数据缓存 |
📡 | Poly 可达性支持 |
🐦 | Swift 5.0 |
需要不同版本的 Swift?
5.0
- 在你的 Podfile 中指定最新的 release 或 master (Cache 更新时会推送)4.2
- 在你的 Podfile 中指定 swift4.2
分支在开始之前,请确保您已阅读 Google Poly 的 文档,了解最佳的署名实践,并已生成您的 API 密钥。
示例项目提供了几个集成示例。
您可以使用命令 pod install
安装依赖项,或者运行 makefile 命令 make setup && make pods
。
# CocoaPods
pod "Poly", "~> 0.4.0"
# Carthage
github "piemonte/Poly" ~> 0.4.0
# Swift PM
let package = Package(
dependencies: [
.Package(url: "https://github.com/piemonte/Poly", majorVersion: 0)
]
)
或者,将 源文件 拖放到您的 Xcode 项目中。
导入库。
import Poly
设置您的 API 密钥。
Poly.shared.apiKey = "REPLACE_WITH_API_KEY"
使用关键字列出资源。
Poly.shared.list(assetsWithKeywords: ["fox"]) { (assets, totalCount, nextPage, error) in
// assets array provides objects with information such as URLs for thumbnail images
}
// you may also query for the data directly for your own model creation
Poly.shared.list(assetsWithKeywords: ["fox", "cat"]) { (data, error) in
}
获取独立的资源信息。
Poly.shared.get(assetWithIdentifier: "10u8FYPC5Br") { (asset, count, page, error) in
// asset object provides information such as URLs for thumbnail images
}
// you may also query for the data directly for your own model creation
Poly.shared.get(assetWithIdentifier: "10u8FYPC5Br") { (data, error) in
}
下载用于渲染的 3D 资源及其依赖资源,可以使用资源标识符或资源模型对象本身。
Poly.shared.download(assetWithIdentifier: "10u8FYPC5Br", progressHandler: { (progress) in
}) { (rootFileUrl, resourceFileUrls, error) in
if let rootFileUrl = rootFileUrl {
let node = SCNNode.createNode(withLocalUrl: rootFileUrl)
self._arView?.scene.rootNode.addChildNode(node)
}
}
该 API 也提供私有对象加载,但可能需要添加额外的端点。 认证支持已设置并可通过 authToken
属性使用。
您可以在此处找到文档。 文档使用 jazzy 生成,并托管在 GitHub-Pages 上。
Poly
在 MIT 许可证下可用,有关更多信息,请参见 LICENSE 文件。