0

I have a simple forge app to view 3d models. At first, I initiated the forge viewer with GuiViewer3D class but then wanted to implement AggregatedView instead.

My problem is that AggregatedView shows the model correctly but it shows it as being "stitched" together. Whereas, if I use GuiViewer3D or Viewer3D, the model looks smooth and clean.

I have looked into the globalOffset but in any solution, the globalOffset is the same, and hence should not be the cause here.

This is how the model should look like (GuiViewer3D) enter image description here

But this is how it looks like instea using AggregatedView

enter image description here

I am not quite sure what the issue here. I am using an .fbx file as the source of 3d model.

This the code of AggregatedView()

var view = new Autodesk.Viewing.AggregatedView();
function launchViewer(urn) {
  var options = {
    env: 'AutodeskProduction',
    getAccessToken: getForgeToken 
  };
  Autodesk.Viewing.Initializer(options, () => {
    var htmlDiv = document.getElementById('forgeViewer');
    
    view.init(htmlDiv, options);
    var documentId = 'urn:' + urn; 
    view.unloadAll();
    Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
  });
}
function onDocumentLoadSuccess(doc) {
var nodes = doc.getRoot().search({ role:'3d', type: 'geometry' });
console.log(nodes);
view.setNodes(nodes[0]);
}

function onDocumentLoadFailure(viewErrorCode, viewErrorMsg) {
  console.error('onDocumentLoadFailure() - errorCode:' + viewErrorCode + '\n- errorMessage:' + viewErrorMsg);
}
function getForgeToken(callback) {
  fetch('/api/forge/oauth/token').then(res => {
    res.json().then(data => {
      callback(data.access_token, data.expires_in);
    });
  });
}

Many thanks in advance!


UPDATE: After setting the global offset to (0,0,0), the geometry still looks "Stitched" together rather than smooth.

enter image description here

M.Matook
  • 11
  • 2

1 Answers1

0

The pivot point is not the global offset. Please use viewer.getAllModels().map( model => model.getGlobalOffset() ) to check that instead. For AggreagateView, you can get the viewer instance via view.viewer;

In addition, AggreagateView loads models in the shared coordinate (applyRefPoint: true), so your model might be far away from the viewer's origin. Could you try this to see if it helps?

const options3d = {
  getCustomLoadOptions: (bubble, data) => {
    console.log(bubble, data);

    return {
      applyRefPoint: false //!<<< Disable Share Coordinate
      // globalOffset: new THREE.Vector3( 543.0811920166016, 9.154923574611564, -1442.591747316564 ) //!<<< uncomment this to specify your globalOffset, but you need to include `applyRefPoint: false` above together.
      // createWireframe: false
    };
  }
};

view.init(viewerDiv, options3d);
Eason Kang
  • 6,155
  • 1
  • 7
  • 24
  • Thank you for the reply. I managed to get the globalOffset like you said but I am not sure how to set it using the AggregatedView so I can if my model looks clear. The documentations do not show how to set globalOffset with SetNodes() method. 0: x: 543.0811920166016 y: 9.154923574611564 z: -1442.591747316564 It is worth to mention that here I am only using one model and still the geometry looks stitched. – M.Matook Aug 12 '22 at 14:15
  • Hi, just pass it in `getCustomLoadOptions`. I updated my example code snippet above. – Eason Kang Aug 16 '22 at 08:27
  • Thank you for replying. I managed to bring the model to (0,0,0) using the line you added. Nevertheless, the model still looks "stitched" together rather than smooth. I used different globalOffset values but still no change. I updated my post with a new screenshot showing the new globalOffset. – M.Matook Aug 16 '22 at 11:27
  • Could you share a reproducible model to `forge (dot) help (at) autodesk (dot) com`? Will need to look into the model. Or just try to turn off the wireframe: https://stackoverflow.com/a/69010035/7745569 – Eason Kang Aug 17 '22 at 09:55
  • The wireframe option actually solved the problem. The geometry looks smooth now using AggregatedView. I assume in GuiViewer3D this option is set to false by default. I am not sure. Thanks a lot for the answer! – M.Matook Aug 24 '22 at 09:31
  • Nice, it's great to hear that. Maybe compare `Display Edges` settings between AggreagatedView and GuiViewer3D. https://i.stack.imgur.com/ZlZyW.png – Eason Kang Aug 24 '22 at 12:02