0

I'm trying to generate a pdf from the viewer adapting threejs-pdf-renderer library. This PDFRenderer needs a Scene and a Camera object in its render method. As per the library example, I should create or pass a scene containing children but when I try with my autodesk-Viewer sample app, the viewer's scene children array (viewer.impl.scene and viewer.impl.sceneAfter) is always empty and I always get a blank PDF.

Is having the viewer's scene children empty as expected? If so, how can I get all drawn elements in order to add it to a new Scene so I can pass this parameter to the PDfRenderer's render method?

I've been trying different solutions without success, even tried adding viewer.model.getConsolidation().meshes array to a scene, but I think it's not the correct way.

Thanks in advance.

1 Answers1

0

The empty scene you got is as expected, Forge viewer is based on three.js, but it does not organize the scene and 3D mesh as the same way in three.js. Within Forge viewer, it has dbid and fragid. A dbId represents the id of a single component that you can see in the model structure (parent or children) or can select visually in the viewer, and one dbId can map to 0 or several fragIds. FragId is actually the one that keeps the information of geometry and material, you can get the geometry and material separately by the API as follow:

 var renderProxy = viewer.impl.getRenderProxy(viewer.model, fragId)
 var fragmentproxy = viewer.impl.getFragmentProxy(viewer.model, fragId)

And for more information, you can check this post of Get THREE.Mesh elements in Autodesk Forge Viewer.

So it means, it's not as simple as to just use viewer.impl.scene, you need to iterate all the fragment, create Mesh based on each fragment, and fill with geometry and material information.

Zhong Wu
  • 1,721
  • 1
  • 8
  • 9