A sample demonstrating how to view a model into web application with the Autodesk View & Data API. This web application has a basic Node.js server and JavaScript/HTML5 client. This sample does not demonstrate how to upload a model ont he Autodesk server for translation.
Install Node.js on your machine and clone this repo. Download the project' dependencies using npm before running the app by running the following command
npm install
on the node.js console. This will install the following node.js modules in the project:
- express
- request
- serve-favicon
This sample does not includes the workflow of uploading models. It depends on other workflow samples to upload models, get model URN. Please follow Setup/Usage Instructions.
Use your own credentials and upload models on your account
- Apply your own credentials from http://developer.autodesk.com
- Replace the place holder with your own keys in credentials.js, line #23 and #25
credentials.ClientId = '<replace with clientId>'; credentials.ClientSecret = '<replace with clientSecret>';
- Upload one of your model in your account and get its URN using other workflow sample, for example,
- this workflow sample in .net winform application if you are using windows
- or this workflow sample in Mac OS Swift if you are using Mac
- or this WEB page
- Copy this URN in /www/views/index.js at line #18
var urnprod = 'your_urn_here';
- Run the server from the Node.js console, by running the following command:
node server.js
- Connect to server locally using a WebGL-compatible browser: http://localhost:3000/
This sample can also work with the Autodesk staging server (vs production) or work with someone else credentials as long you can get a valid token. By default, the project is setup with the production server, and use your own credentials. If you are interested by a different setup, see the Options below.
You can work with production or staging Autodesk View and Data environments. By default, the project is setup with the production server.
Option A: Production server option: Use upload tool online service to upload model.
- The upload tool provides some existing models. Choose any one of them, or upload one of your own models with upload tool. The upload tool will generate a URN of the model that you need later.
- Copy this URN in /www/views/index.js at line #18
var urnprod = 'your_urn_here';
- In /www/views/index.js, at line #36, change value of tokenurl to the access token you can generate from 'http://still-spire-1606.herokuapp.com/api/rawtoken'
- Run the server from the Node.js console, by running the following command:
node server.js
- Connect to server locally using a WebGL-compatible browser: http://localhost:3000/
Option B: To work with the staging environment, you need to use your own credential vs the option above.
- Apply your own credentials from http://developer-stg.autodesk.com
- Replace the place holder with your own keys in credentials-stg.js, line #23 and #25
credentials.ClientId = '<replace with clientId>'; credentials.ClientSecret = '<replace with clientSecret>';
- Upload one of your model in your account and get its URN using other workflow sample,for example,
- this workflow sample in .net winform application if you are using windows
- or this workflow sample in Mac OS Swift if you are using Mac But please use staging URL to proceed with the workflows.
- Copy this URN in /www/views/index.js at line #19
var urnstg = 'your_urn_here';
- In /www/views/index.js, around line #24, make sure the variable staging is true.
- In /www/views/index.html (line $33 and #34), use viewer3D.min.js and style.css from the staging environment
<link type="text/css" rel="stylesheet" href="https://developer-stg.api.autodesk.com/viewingservice/v1/viewers/style.css"/> <script src="https://developer-stg.api.autodesk.com/viewingservice/v1/viewers/viewer3D.min.js"></script>
- Run the server from the Node.js console, by running the following command:
node server.js
- Connect to server locally using a WebGL-compatible browser: http://localhost:3000/
That samples are licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Written by Philippe Leefsma