Trying to add custom mesh to offline viewer

I try to add a custom sphereMesh to a offline viewer. I saw this can be done with the online version of the viewer. But I get an uncaught TypeError: Cannot read property 'Add' of undefined if I try this in my viewer.

<div id="MyViewerDiv"></div>

           var myViewerDiv = document.getElementById('MyViewerDiv');
            var viewer = new Autodesk.Viewing.Private.GuiViewer3D(myViewerDiv);
      var options = {
          'env' : 'Local',
         'document' : './_3D_ 197440/_3D_.svf'
      Autodesk.Viewing.Initializer(options, function() {
        viewer.start(options.document, options);

     var geom = new THREE.SphereGeometry(1000, 8, 8);
     var material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
     var sphereMesh = new THREE.Mesh(geom, material);
     sphereMesh.position.set(0, 0, 0);



There is no difference between online and offline viewer, when it comes to ways of adding custom geometry. In your case you have a situation similar to "race condition", where you try to use a resource while it is initializing: sometimes the init process finishes first => success, sometimes it finishes later => get errors.

To solve the problem, there are 2 approaches:

  1. Add your code into an extension and load extension as mentioned in documentation (the recommended one). Example:
  2. Move your custom mesh code into the body of the document loading callback function. Example: Check the source of


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.