When I migrate my Forge Viewer from SVF to SVF2, some of the geometry is not loaded and I get "Invalid OGT header" and "Failed to parse OGT geometry" for each element.
Console error
I'm obtaining the models directly from BIM360.
I'm using Nodejs with express and doing a post request to communicate Forge access token with the client
app.get('/home', (req, res) => {
var options = {
'method': 'POST',
'url': 'https://developer.api.autodesk.com/authentication/v1/authenticate',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'PF=boZ6jpDwlNEmVzAGFiFx8i'},
form: {
'grant_type': 'client_credentials',
'client_id': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'client_secret': 'XXXXXXXXXXXXXXXXXX',
'scope': 'data:read data:write'}};
I just replaced the SVF viewer options with the ones in the Autodesk Post
function launchViewer(urn) {
//SVF
//var options = {
//env: 'AutodeskProduction',
//getAccessToken: getToken,
//api: 'derivativeV2' + (atob(urn.replace('_', '/')).indexOf('emea') > -1 ? '_EU' : '')};
//SVF2
var options = {
env: 'MD20ProdUS',
getAccessToken: getToken,
api: 'D3S'};
Autodesk.Viewing.Initializer(options, () => {
viewer = new Autodesk.Viewing.Viewer3D(document.getElementById('forgeViewer'));
viewer.start();
var documentId = 'urn:' + urn;
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);});
function onDocumentLoadSuccess(doc) {
var viewables = doc.getRoot().getDefaultGeometry();
viewer.loadDocumentNode(doc, viewables).then((i) => {
// documented loaded, any action?
});
this.viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, onSelectionChanged);
this.viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, onGeometryLoaded);
}
function onGeometryLoaded(){
console.log(viewer);
}
function onDocumentLoadFailure(viewerErrorCode) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}}
Finally obtain the token from the server
//Localhost
function getToken(_callback) {
$.get("http://localhost:3000/home", function(data, status){
var response = JSON.parse(data);
_callback(response.access_token, response.expires_in);
});
}
Any clue what might be happening here?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…