Coder Social home page Coder Social logo

lemsdentsu / samples-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from avatarsdk/samples-js

0.0 0.0 0.0 326 KB

How to interact with AvatarSDK WEB API in JavaScript

License: BSD 3-Clause "New" or "Revised" License

Shell 0.01% JavaScript 99.53% CSS 0.23% HTML 0.24%

samples-js's Introduction

AvatarSDK WEB API JS sample

In this sample, you could find how to query the available avatar computation/export parameters, create an avatar computation task, poll its status and download avatar export files using JavaScript.

How to start

You will need to complete the following steps before experimenting with this sample:

Now you are ready to go:

  • Clone this repository to your computer
  • Run serve.sh script to start a simple web server (requires python3 installed) and navigate to http://localhost:9000
  • Fill client_id and client_secret fields with the corresponding values from the Developer page above and click Authorize button
  • See running requests in your browser developer tools

How it works

asdk.js wraps API calls, since every request must include Authorization header. It also parses JSON responses and handles request errors. Every AvatarSDK method returns a Promise

avatars_ui.js wraps UI/UX. It initializes AvatarSDK and then:

  • build avatar computation and export parameters forms dynamically, based on API response (see fillParametersGui and fillExportParametersGui)
  • visualize selected parameters (see generateComputationParameters and generateExportParameters)
  • generate additional export parameters for avatar visualization, based on the selected export parameters (i.e. predefined format and textures parameters and the first asset from haircuts/outfits. See generateVisualExportParameters)
  • create and poll avatar computation task (see onComputeAvatar)
  • visualize avatar (see visualizeExport)
  • build available export files form (see fillExportsGUI)
  • download export files (see downloadExportFile)

avatars_gl.js wraps 3D rendering. It initializes the rendering scene, controls, and adds avatar model into the scene properly (i.e. adjust some material properties, see _adjustMeshProperties). Please note: only GLB with embedded meshes and textures are supported now, so we add the second group of export parameters to request this format of mesh simultaneously with the user-selected ones (see generateExportParameters at avatars_ui.js).

main.js wraps authorization UI/UX. Please see the note on authorization below.

This sample uses the following libraries:

Note on the authorization

Avatar SDK WEB API uses OAuth 2.0 for authorization. The authorization token retrieval form is present here purely for the sample purpose. Production code must keep client_id and client_secret secret, perform authorization on the server-side and provide frontend only with access_token (i.e. pass the token within config into avatars_ui.js :: init(config) call).

License

The 3-Clause BSD License

See LICENSE.md

samples-js's People

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.