-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path01.html
103 lines (77 loc) · 3.17 KB
/
01.html
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
<html>
<head>
<meta charset="UTF-8">
<title>SD226781_Samples</title>
<!-- Autodesk Forge libs-->
<link rel="stylesheet" href="https://developer.api.autodesk.com/modelderivative/v2/viewers/6.*/style.min.css" type="text/css">
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/6.*/viewer3D.min.js"></script>
<!-- custom libs-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js" integrity="sha256-kCykSp9wgrszaIBZpbagWbvnsHKXo4noDEi6ra6Y43w=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./css/main.css" type="text/css">
<script src="./extensions/EditorExt.js"></script>
</head>
<body>
<div id="page_navigation">
<a href="./00.html" class="arrow-left" ></a>
<span> Simple Extension </span>
<a href="./01b.html" class="arrow-right"></a>
</div>
<!-- The Viewer will be instantiated here -->
<div id="MyViewerDiv"></div>
</body>
<!-- Developer JS -->
<script>
const divID = 'MyViewerDiv';
const documentId = 'urn:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6ZXhwZXJpbWVudF9yZXBvL0hlbGxvJTIwV29ybGQucnZ0';
const tokenFetchingUrl = "https://9irt90dm6j.execute-api.us-east-1.amazonaws.com/prod";
let extensionArray = [];
let viewerApp = new Autodesk.Viewing.ViewingApplication(divID);
let viewer = null;
let options = {
env: 'AutodeskProduction',
getAccessToken: (onGetAccessToken) => {
fetch(tokenFetchingUrl)
.then(response => response.json())
.then(data => {
let accessToken = data["access_token"];
let expireTimeSeconds = data["expires_in"];
onGetAccessToken(accessToken, expireTimeSeconds);
})
},
useADP: false,
};
let config3d = {
extensions: extensionArray
};
Autodesk.Viewing.Initializer(options, function onInitialized() {
viewerApp.registerViewer(viewerApp.k3D, Autodesk.Viewing.Private.GuiViewer3D, config3d);
viewerApp.loadDocument(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
// Init after the viewer is ready
function onDocumentLoadSuccess() {
let viewables = viewerApp.bubble.search({
'type': 'geometry'
});
if (viewables.length === 0) {
console.error('Document contains no viewables.');
return;
}
// Choose any of the available viewables
viewerApp.selectItem(viewables[0].data, onItemLoadSuccess, onItemLoadFail);
}
function onDocumentLoadFailure(viewerErrorCode) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}
function onItemLoadSuccess(active_viewer, item) {
console.log('Document loaded successfully');
viewer = active_viewer;
viewer.loadExtension('EditorExtension').then(
function(myExtension) {
myExtension.setExtensionParams("TemplateExtension", "/extensions/templateExt.js");
})
}
function onItemLoadFail(errorCode) {
console.error('onItemLoadFail() - errorCode:' + errorCode);
}
</script>
</html>