Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

Autodesk Forge Viewer - Invalid OGT header with SVF2 format

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We are using SVF2 since 2 months and are now experiencing this problem for one of our models which worked without a problem before. However, most models work fine. It seems SVF2 regressed.

However, we use the EMEA environment:

{
     'env': 'MD20ProdEU', //svf2
     'api': 'D3S', //svf2
     ...
}

Chrome dev tools error message

Edit:

I researched a little bit more. Our local development instance hosted on port 1841 has the error only for one model. Our properly hosted viewer instance on port 80 has no error for the same model. (Tested for viewer version 7.34 and 7.33)

Edit 2:

Related Stackeoverflow question without an answer unfortunetely: Forge Viewer - Failed to parse OTG


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...