Search code examples
autodesk-forgeautodesk-viewerautodesk

Autodesk GuiViewer3D initialize gives an error


Following is my code

Autodesk.Viewing.Initializer(options, function () {
    var htmlDiv = document.getElementById('forgeViewer');
    viewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv);
    var startedCode = viewer.start();
    if (startedCode > 0) {
        console.error('Failed to create a Viewer: WebGL not supported.');
        return;
    }

but it still gives an error as follows

error

Please advise me where I have done wrong ?

using viewer V6

update :

 var htmlDiv = document.getElementById('forgeViewer');
 viewer = new Autodesk.Viewing.Private.GuiViewer3D(htmlDiv);

error stack

SettingsPanel.js:377 Uncaught TypeError: Cannot read property 'tBodies' of null
    at v.l.addCheckbox (SettingsPanel.js:377)
    at v.addCheckbox (ViewerSettingsPanel.js:137)
    at v.createNavigationPanel (ViewerSettingsPanel.js:328)
    at new v (ViewerSettingsPanel.js:64)
    at D.createSettingsPanel (GuiViewer3D.js:837)
    at D.initModelTools (GuiViewer3D.js:926)
    at D.createUI (GuiViewer3D.js:369)
    at GuiViewer3D.js:291
    at GuiViewer3D.js:301
l.addCheckbox   @   SettingsPanel.js:377
v.addCheckbox   @   ViewerSettingsPanel.js:137
v.createNavigationPanel @   ViewerSettingsPanel.js:328
v   @   ViewerSettingsPanel.js:64
D.createSettingsPanel   @   GuiViewer3D.js:837
D.initModelTools    @   GuiViewer3D.js:926
D.createUI  @   GuiViewer3D.js:369
(anonymous) @   GuiViewer3D.js:291
(anonymous) @   GuiViewer3D.js:301

new error

Thank you Cheers


Solution

  • In version 6 and older, the GuiViewer3D class is in a different namespace: Autodesk.Viewing.Private.GuiViewer3D.

    Since version 7 the fully qualified name is Autodesk.Viewing.GuiViewer3D.