Use Poly API for ARKit

Poly

Poly API

Usage

Use data of Poly in ARKit/SceneKit

import SceneKit
import SceneKit.ModelIO
import ModelIO
// create instance of MDLAsset
let mdlAsset = MDLAsset(url: objURL)
// load texture
mdlAsset.loadTextures()
// create instance of SCNNode
let node = SCNNode(mdlObject: mdlAsset.object(at: 0))

PolyKit

github “fromkk/PolyKit”

Usage

import PolyKit
let query = PolyAssetsQuery(keywords: “Cat”, format: Poly3DFormat.obj)
let polyApi = PolyAPI(apiKey: “Poly API Key is HERE!!!”)
polyApi.assets(with: query) { (result) in
switch result {
case .success(let assets):
self.dataSource.assets = assets.assets ?? []
case .failure(_):
self.showFetchFailedAlert()
}
}

Download files of .obj and .mtl

import PolyKit
import SceneKit
import SceneKit.ModelIO
import ModelIOlet asset: PolyAsset = …
// Download obj and mtl files from Poly
asset.downloadObj { (result) in
switch result {
case .success(let localUrl):
let mdlAsset = MDLAsset(url: localUrl)
mdlAsset.loadTextures()
let node = SCNNode(mdlObject: mdlAsset.object(at: 0))
// do something with node
case .failure(let error):
debugPrint(#function, “error”, error)
}
}

Summary

Kakkun a.k.a. fromKK

Written by

I'm iOS apps engineer in Timers Inc, in Japan. I went to WWDC in 2016 and 2017.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade