-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathindex.js
105 lines (95 loc) · 3.98 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/////////////////////////////////////////////////////////////////////////////////
// Copyright (c) Autodesk, Inc. All rights reserved
// Written by Philippe Leefsma 2014 - ADN/Developer Technical Services
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
/////////////////////////////////////////////////////////////////////////////////
var defaultUrn = 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bW9kZWwyMDE1LTA1LTExLTA5LTE2LTEwLWdlN3B4aXNzNDF0eGRqdHhxa3R4eTN3MWc2emUvUm9ib3RBcm0uZHdmeA==';
$(document).ready(function () {
var tokenurl = 'http://' + window.location.host + '/api/token';
var config = {
environment : 'AutodeskProduction'
//environment : 'AutodeskStaging'
};
// Instantiate viewer factory
var viewerFactory = new Autodesk.ADN.Toolkit.Viewer.AdnViewerFactory(
tokenurl,
config);
// Allows different urn to be passed as url parameter
var paramUrn = Autodesk.Viewing.Private.getParameterByName('urn');
var urn = (paramUrn !== '' ? paramUrn : defaultUrn);
viewerFactory.getViewablePath (urn,
function(pathInfoCollection) {
var viewerConfig = {
viewerType: 'GuiViewer3D'
};
var viewer = viewerFactory.createViewer(
$('#viewerDiv')[0],
viewerConfig);
viewer.load(pathInfoCollection.path3d[0].path);
},
onError);
});
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();
// });