Code Monkey home page Code Monkey logo

poly's Introduction

Poly

Poly is an unofficial Google Poly SDK, written in Swift.

This library makes it easy to integrate with Google Poly while providing a few additional client-side features.

Build Status Pod Version Swift Version GitHub license

Features
🔍 3D model search
3D model download management
📦 advanced 3D data caching
📡 Poly reachability support
🐦 Swift 5.0

Need a different version of Swift?

  • 5.0 - Target your Podfile to the latest release or master (will push when Cache updates)
  • 4.2 - Target your Podfile to the swift4.2 branch

Important

Before you begin, ensure that you have read Google’s Poly documentation, understand best practices for attribution, and have generated your API key.

Quick Start

The sample project provides several examples for integration.

You can install the dependencies with the command pod install or by running the makefile commands make setup && make pods.

# CocoaPods

pod "Poly", "~> 0.2.0"

# Carthage

github "piemonte/Poly" ~> 0.2.0

# Swift PM

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/piemonte/Poly", majorVersion: 0)
    ]
)

With Xcode 10.2, one of Poly's dependencies currently requires this script in your Podfile post install.

This is only required until this PR has landed.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'Cache'
      target.build_configurations.each do |config|
        level = '-Osize'
        config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = level
        puts "Set #{target.name} #{config.name} to Optimization Level #{level}"
      end
    end
  end
end

Alternatively, drop the source files into your Xcode project.

Examples

Import the library.

import Poly

Setup your API key.

Poly.shared.apiKey = "REPLACE_WITH_API_KEY"

List assets using keywords.

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
}

Get independent asset information.

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
}

Download a 3D asset and it's resources for rendering, either using the asset identifier or the asset model object itself.

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

The API also provides private object loading but additional endpoints may need to be added. Auth support is setup and available via the authToken property.

Documentation

You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.

Resources

License

Poly is available under the MIT license, see the LICENSE file for more information.

poly's People

Contributors

piemonte avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.