Created
October 21, 2016 08:21
-
-
Save leefsmp/0afdb89de1971187ad402bb2b37fbc2e to your computer and use it in GitHub Desktop.
Illustrates how to load document offline/online with Forge Viewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async onViewerCreated (data) { | |
try { | |
const { viewer, initialize, loadDocument } = data | |
viewer.addEventListener( | |
Autodesk.Viewing.FULLSCREEN_MODE_EVENT, (e) => { | |
this.onFullScreenMode(e) | |
}) | |
const modelId = this.props.location.query.id | |
this.model = await this.modelSvc.getModel( | |
'forge-rcdb', | |
modelId) | |
if(!this.viewerEnvInitialized) { | |
this.viewerEnvInitialized = true | |
await initialize( | |
this.model.env, | |
'/api/forge/token/2legged') | |
} | |
viewer.start() | |
switch (this.model.env) { | |
case 'Local': | |
viewer.load(this.model.path) | |
break | |
case 'AutodeskProduction': | |
const doc = await loadDocument( | |
'urn:' + this.model.urn) | |
const path = ViewerToolkit.getDefaultViewablePath(doc) | |
viewer.loadModel(path) | |
break | |
} | |
this.viewer = viewer | |
} catch(ex) { | |
console.log('Viewer Initialization Error: ') | |
console.log(ex) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment