To use Google Poly, you will first need to enable the API in the Google API project console.
Google Poly API requires that you serve your content through a web server. So let’s spin up a simple NodeJS server:
const express = require('express') const app = express() app.use(express.static('public')) app.listen(3000, () => console.log('Serving!'))
Notice that we are serving files in a folder called static. Where are you going to get those files? You can download the Google Poly API demo project here. Rename the basic-sample.html to index.html and move the whole demo project to your public folder.
Change Some Stuff
It’s important that you change your API key inside of the index.html file (line 108). Also, if you want to grab another object from Poly, you can find the object id in the URL and send it to your loadAsset function (line 170). Once you run your webserver, you should get a simple 3D scene. It takes a few moments for the 3D object to download from Poly, so be patient.