Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Poly API for ARKit #akibaswift /poly_api_for_ar...

fromkk
December 11, 2017

Poly API for ARKit #akibaswift /poly_api_for_arkit_akibaswift

2017年 AKIBA.swift忘年回で発表した内容です。Poly APIを使ってみてライブラリを作った事を発表してきました。

fromkk

December 11, 2017
Tweet

More Decks by fromkk

Other Decks in Programming

Transcript

  1. ARKit/SceneKitͰͷ࢖͍ํ • asset.formats.root.url(.obj), asset.formats.resources.url(.mtl) ΛϩʔΧϧʹμ΢ϯ ϩʔυ import SceneKit import SceneKit.ModelIO

    import ModelIO // MDLAssetΠϯελϯεΛੜ੒ let mdlAsset = MDLAsset(url: objURL) // ςΫενϟΛಡΈࠐΉ mdlAsset.loadTextures() // SCNNodeΛੜ੒ let node = SCNNode(mdlObject: mdlAsset.object(at: 0)) 18
  2. Usage Fetch assets 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() } } 21
  3. Download .obj and .mtl from Poly API. import PolyKit let

    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) } } 22