Note: This repo is also used by our tutorial material. If you are following instructions from our tutorial, please ignore the instructions below.
This sample demonstrates how to view a model in a web application with the Autodesk View & Data API. This web application implements a basic Node.js server and JavaScript/HTML5 client. It does not demonstrate how to upload a model to the Autodesk server for translation. See instructions below on how to prepare a model to be consumed in this sample.
Install Node.js on your machine and clone this repo. Download the project dependencies using npm by running the following command in the project root directory:
npm install
This will install the following node.js modules in the project:
"serve-favicon": ">= 2.2.0",
"express": ">= 4.12.3",
"request": ">= 2.55.0",
"view-and-data": "^1.0.6",
"bower": "^1.6.5"
-
Apply for your own credentials (API keys) from developer.autodesk.com
-
There is 3 ways to setup the sample with your API keys
-
Edit the routes/credentials.js file
-
Edit the routes/api.js file
-
Edit the node_modules/view-and-data/config-view-and-data.js file (avoid that option)
-
Set environment variables
set CONSUMERKEY=<put your consumer key here> set CONSUMERSECRET=<put your consumer secret here>
-
The simplest way to get a model ready is to use this service. Enter your API keys, uplaod a model, wait for the model to be translated, and copy the resulting URN.
- Copy the URN which was generated in the previous step in files
- /www/index.js at line #21
- /www/index-old.js at line #21
- /www/index-pure.js at line #21
- /www/requirejs/app-init.js at line #21
var defaultUrn = '<replace with your encoded urn>';
Note: the URN needs to be base64 encoded as mentioned here under "Step 6: Register Your Data with the Viewing Services"
-
Run the server from the Node.js console, by running the following command:
node start.js
or
npm start
-
Connect to you local server using a WebGL-compatible browser: http://localhost:3000/
- index.html is a version which uses the new view-and-data-toolkit
you can install use bower.
bower install view-and-data-toolkit --save
- index-old.html is the older version of the view-and-data-toolkit which is accessed directly from github.
- index-pure.html is a version using the View & Data API without the toolkit. Pure because it is raw API.
- index-requirejs.html is a version that uses require.js to manage javascript modules using the latest view-and-data-toolkit (1).
- index.html is a version which uses the new view-and-data-toolkit
you can install use bower.
Note: the 4 html/js do exactly the same thing. Only the coding is different.
That samples are licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Philippe Leefsma, Autodesk Developer Network.
and Cyrille Fauvel (Autodesk Developer Network)
http://www.autodesk.com/adn
http://around-the-corner.typepad.com/