diff --git a/README.md b/README.md index 4747555..c044bf4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![build status](https://api.travis-ci.org/Developer-Autodesk/workflow-node.js-view.and.data.api.png)](https://travis-ci.org/Developer-Autodesk/workflow-node.js-view.and.data.api) - +[![LMV](https://img.shields.io/badge/View%20%26%20Data%20API-v1.2.15-green.svg)](http://developer-autodesk.github.io/) @@ -39,9 +39,9 @@ It depends on other workflow samples to upload models and retrieve the model URN ``` * Replace the placeholders with your own keys in credentials.js, line #23 and #24
``` - client_id: process.env.CONSUMERKEY || ''; + client_id: process.env.CONSUMERKEY || '', - client_secret: process.env.CONSUMERSECRET || ''; + client_secret: process.env.CONSUMERSECRET || '', ``` * Upload one of your models to your account and get its URN using another workflow sample, for example: - Windows: [.NET WPF application workflow sample](https://github.com/Developer-Autodesk/workflow-wpf-view.and.data.api) diff --git a/www/index.html b/www/index.html index 752901b..800de41 100644 --- a/www/index.html +++ b/www/index.html @@ -30,11 +30,11 @@ - - + + - + diff --git a/www/index.js b/www/index.js index ae9639c..5240042 100644 --- a/www/index.js +++ b/www/index.js @@ -53,52 +53,66 @@ function onError(error) { console.log('Error: ' + error); }; +/* // The following code does not rely on Autodesk.ADN.Toolkit.Viewer.AdnViewerManager // and uses the Autodesk API directly. -// -// $(document).ready(function () { -// var getToken = function() { -// var xhr = new XMLHttpRequest(); -// xhr.open("GET", 'http://' + window.location.host + '/api/token', false); -// xhr.send(null); -// return xhr.responseText; -// } -// -// function initializeViewer(containerId, documentId, role) { -// var viewerContainer = document.getElementById(containerId); -// var viewer = new Autodesk.Viewing.Private.GuiViewer3D( -// viewerContainer); -// viewer.start(); -// -// Autodesk.Viewing.Document.load(documentId, -// function (document) { -// var rootItem = document.getRootItem(); -// var geometryItems = Autodesk.Viewing.Document.getSubItemsWithProperties( -// rootItem, -// { 'type': 'geometry', 'role': role }, -// true); -// -// viewer.load(document.getViewablePath(geometryItems[0])); -// }, -// -// // onErrorCallback -// function (msg) { -// console.log("Error loading document: " + msg); -// } -// ); -// } -// -// function initialize() { -// var options = { -// env: "AutodeskProduction", -// getAccessToken: getToken, -// refreshToken: getToken -// }; -// -// Autodesk.Viewing.Initializer(options, function () { -// initializeViewer('viewerDiv', urn, '3d'); -// }); -// } -// -// initialize(); -// }); + + $(document).ready(function () { + var getToken = function() { + var xhr = new XMLHttpRequest(); + xhr.open("GET", 'http://' + window.location.host + '/api/token', false); + xhr.send(null); + + var response = JSON.parse( + xhr.responseText); + + return response.access_token; + } + + function initializeViewer(containerId, documentId, role) { + var viewerContainer = document.getElementById(containerId); + var viewer = new Autodesk.Viewing.Private.GuiViewer3D( + viewerContainer); + viewer.start(); + + Autodesk.Viewing.Document.load(documentId, + function (document) { + var rootItem = document.getRootItem(); + var geometryItems = Autodesk.Viewing.Document.getSubItemsWithProperties( + rootItem, + { 'type': 'geometry', 'role': role }, + true); + + viewer.load(document.getViewablePath(geometryItems[0])); + }, + + // onErrorCallback + function (msg) { + console.log("Error loading document: " + msg); + } + ); + } + + function initialize() { + var options = { + env: "AutodeskProduction", + getAccessToken: getToken, + refreshToken: getToken + }; + + // Allows different urn to be passed as url parameter + var paramUrn = Autodesk.Viewing.Private.getParameterByName('urn'); + var urn = (paramUrn !== '' ? paramUrn : defaultUrn); + + if (urn.indexOf('urn:') !== 0) + urn = 'urn:' + urn; + + Autodesk.Viewing.Initializer(options, function () { + initializeViewer('viewerDiv', urn, '3d'); + }); + } + + initialize(); + }); + +*/ \ No newline at end of file