|
1 | | -#Autodesk view and data API Node.js Basic Sample |
| 1 | +# Autodesk View and Data API Node.js Basic Sample |
2 | 2 |
|
3 | 3 |
|
4 | | -##Description |
5 | | - |
6 | | - |
7 | | -A sample demonstrating how to load a model into web application with the Autodesk View & Data API. This web application has a basic Node.js server and JavaScript/HTML5 client |
8 | | - |
9 | | -##Dependencies |
| 4 | +## Description |
| 5 | +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. |
10 | 6 |
|
| 7 | +## Dependencies |
11 | 8 | 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 |
12 | 9 | ``` |
13 | 10 | npm install |
14 | 11 | ``` |
15 | | -on the node.js console. This will install the following node.js modules in the project. |
| 12 | +on the node.js console. This will install the following node.js modules in the project: |
16 | 13 | - express |
17 | 14 | - request |
18 | 15 | - serve-favicon |
19 | 16 |
|
20 | 17 | 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. |
21 | 18 |
|
22 | | -##Setup/Usage Instructions |
23 | | - |
24 | | -You can work with production or staging Autodesk View and Data environments. By default, the project is setup with the production server. |
25 | | - |
26 | | -With the production server, you got 2 options to setup and run this sample. |
| 19 | +## Setup/Usage Instructions |
| 20 | +Use your own credentials and upload models on your account |
27 | 21 |
|
28 | | -### Option A: Use [upload tool](http://still-spire-1606.herokuapp.com) online service to upload model. |
29 | | - |
30 | | -* The [upload tool](http://still-spire-1606.herokuapp.com) provides some existing models. Choose any one of them, or upload one of your own models with [upload tool](http://still-spire-1606.herokuapp.com). The [upload tool](http://still-spire-1606.herokuapp.com) will generate a URN of the model that you need later. |
| 22 | +* Apply your own credentials from [http://developer.autodesk.com](http://developer.autodesk.com) |
| 23 | +* Replace the place holder with your own keys in credentials.js, line #23 and #25 <br /> |
| 24 | + ``` |
| 25 | + credentials.ClientId = '<replace with clientId>'; |
| 26 | + |
| 27 | + credentials.ClientSecret = '<replace with clientSecret>'; |
| 28 | + ``` |
| 29 | +* 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](https://github.com/Developer-Autodesk/workflow-dotnet-winform-view.and.data.api/) if you are using windows or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac. |
31 | 30 | * Copy this URN in /www/views/index.js at line #18 <br /> |
32 | 31 | ``` |
33 | 32 | var urnprod = 'your_urn_here'; |
34 | 33 | ``` |
35 | | -* 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' |
36 | 34 | * Run the server from the Node.js console, by running the follwing command: <br /> |
37 | 35 | ``` |
38 | 36 | node server.js |
39 | 37 | ``` |
40 | 38 | * Connect to server locally using a WebGL-compatible browser: [http://localhost:3000/node/basic](http://localhost:3000/node/basic) |
41 | 39 |
|
42 | | -### Option B: Use your own credentials and upload models on your account |
43 | | - |
44 | | -* Apply your own credentials from [http://developer.autodesk.com](http://developer.autodesk.com) |
45 | | -* Replace the place holder with your own keys in credentials.js, line #23 and #25 <br /> |
46 | | - ``` |
47 | | - credentials.ClientId = '<replace with clientId>'; |
48 | | - |
49 | | - credentials.ClientSecret = '<replace with clientSecret>'; |
50 | | - ``` |
51 | | -* 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](https://github.com/Developer-Autodesk/workflow-dotnet-winform-view.and.data.api/) if you are using windows or [this workflow sample in Mac OS Swift](https://github.com/Developer-Autodesk/workflow-macos-swift-view.and.data.api) if you are using Mac. |
| 40 | + |
| 41 | +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. |
| 42 | + |
| 43 | +## Options |
| 44 | + |
| 45 | +You can work with production or staging Autodesk View and Data environments. By default, the project is setup with the production server. |
| 46 | + |
| 47 | +### Production server option: Use [upload tool](http://still-spire-1606.herokuapp.com) online service to upload model. |
| 48 | + |
| 49 | +* The [upload tool](http://still-spire-1606.herokuapp.com) provides some existing models. Choose any one of them, or upload one of your own models with [upload tool](http://still-spire-1606.herokuapp.com). The [upload tool](http://still-spire-1606.herokuapp.com) will generate a URN of the model that you need later. |
52 | 50 | * Copy this URN in /www/views/index.js at line #18 <br /> |
53 | 51 | ``` |
54 | 52 | var urnprod = 'your_urn_here'; |
55 | 53 | ``` |
| 54 | +* 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' |
56 | 55 | * Run the server from the Node.js console, by running the follwing command: <br /> |
57 | 56 | ``` |
58 | 57 | node server.js |
59 | 58 | ``` |
60 | 59 | * Connect to server locally using a WebGL-compatible browser: [http://localhost:3000/node/basic](http://localhost:3000/node/basic) |
61 | 60 |
|
62 | | -#### To work with the staging environment, you need to use Option B. |
| 61 | + |
| 62 | +### To work with the staging environment, you need to use your own credential vs the option above. |
63 | 63 | * Apply your own credentials from [http://developer-stg.autodesk.com](http://developer-stg.autodesk.com) |
64 | 64 | * Replace the place holder with your own keys in credentials-stg.js, line #23 and #25 <br /> |
65 | 65 | ``` |
|
0 commit comments