5月 6, 2021

403 error when trying to view SVF2

Some people ran into a 403 error when trying to view the SVF2 of their models - see picture on top.

The issue is that the acmSessionId needs to be set for the options that you pass to loadModel()

If you are using loadDocumentNode(), which wraps loadModel(), then it will set that value for you, and using that function is the best way going forward.
That function too supports options as input, so have all the capabilities that calling loadModel() directly provides.

Just for completeness' sake, here is how you could avoid the error if you were to stick to calling loadModel() directly:

function onDocumentLoadSuccess(doc) {
    let items = doc.getRoot().search({
        'type': 'geometry',
        'role': '3d'
    }, true)

    let url = doc.getViewablePath(items[0])
    
    viewer.loadModel(url, { acmSessionId: doc.getAcmSessionId(url) })
}

 

Related Posts