🤖 Merge PR #45787 Fix field defs for Document of forge-viewer by @yiskang

This commit is contained in:
Eason Kang 2020-07-09 06:22:50 +08:00 committed by GitHub
parent cb01078884
commit 1bc371109e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 2 deletions

View File

@ -0,0 +1,36 @@
let viewer: Autodesk.Viewing.GuiViewer3D;
const options = {
env: 'AutodeskProduction',
api: 'derivativeV2', // for models uploaded to EMEA change this option to 'derivativeV2_EU'
accessToken: ''
};
Autodesk.Viewing.Initializer(options, () => {
const htmlDiv = document.getElementById('forgeViewer');
if (!htmlDiv)
return;
viewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv);
const startedCode = viewer.start();
if (startedCode > 0) {
console.error('Failed to create a Viewer: WebGL not supported.');
return;
}
const documentId = 'urn:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXktYnVja2V0L215LWF3ZXNvbWUtZm9yZ2UtZmlsZS5ydnQ';
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
async function onDocumentLoadSuccess(doc: Autodesk.Viewing.Document) {
await doc.downloadAecModelData();
const docRoot: Autodesk.Viewing.BubbleNode = doc.getRoot();
const aecModelData = await Autodesk.Viewing.Document.getAecModelData(docRoot);
const defaultModel = docRoot.getDefaultGeometry();
await viewer.loadDocumentNode(doc, defaultModel);
}
function onDocumentLoadFailure() {
console.error('Failed fetching Forge manifest');
}
});

View File

@ -386,7 +386,7 @@ declare namespace Autodesk {
myData: any;
downloadAecModelData(onFinished?: (data: any) => void): Promise<any>;
getAecModelData(node: BubbleNode): any;
static getAecModelData(node: BubbleNode): any;
getFullPath(urn: string): string;
getItemById(id: string): object;
getMessages(itemId: string, excludeGlobal: boolean): object;

View File

@ -18,6 +18,7 @@
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
"index.d.ts",
"forge-viewer-tests.ts"
]
}