Autodesk View and Data supports various file formats in industry. This depends on the various translators running on the cloud. When a source CAD model file is being translated (in API, the service is called Register), the logical structure of the source model is converted to the equivalent Viewer scene graph. This is what we can see in the panel of [Model Structure]. This is above the scene to the end user, which almost keeps the similar model structure in the source CAD software.
While to have the excellent performance, particularly with large model, there must be some kind of re-organizing of the mesh data. There is not an statement yet on how View is working, however from some points of the API objects and my experience of Navisworks, I’d guess behind the scene, Viewer might be similar to that of Navisworks, i.e. during conversion, the hierarchical scene graph of the logical structure is flattened, while still preserving instancing of geometry. Each instance of a Geometry node is represented by one or more Fragments in the spatial data structure. Each Fragment contains epitomized versions of the Geometry, Transform and Appearance attributes from the original scene graph.
Large Geometry may be broken into multiple Fragments for more efficient displaying. Each fragment provides access to:
> The complete transform matrix from local to world space.
> The geometry used to display the fragment.
> The appearance/material used to display the fragment.
model.getData().fragments returns the fragments collection. The object of the logic structure has DbID. Each fragment has a Id too. Model.Fragments provides the array that you can get the corresponding DbId from a fragment Id. It also provides the the array that you can get cooresponding object node from a fragment.
function GlobalFrag() {
//get the model
var geometry = _viewer.model.getData();
// overall fragments of the model
var fragments = geometry.fragments;
//index array, get dbId from fragment
var arrayOfFragToDbId = fragments.frgId2DbIds;
//get object node from fragment
var arrayofFragToNode = fragments.frgId2DbNode;
}
The model.getData().fragments object uses SoA storage (structure of arrays, instead of AoS, array of structures), so the data for each geometry fragment is spread across several arrays contained by the fragments object. But generally you probably won't have to deal with that directly.
In many scenarios, we would run our workflow in the event: SELECTION_CHANGED_EVENT. When the item is selected, it also tells the information of the fragments.
Note: There is currently no setting to control selection depth/granularity like Navisworks. So in default, this event always returns the geometry node when clicking an object in the canvas.
//delegate the event of selection
_viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT,
onSelectedCallback);
//select event
function onSelectedCallback(event) {
//check the first object in the selection
var fragId = event.fragIdsArray[0];
//if something is selected
if (typeof fragId !== 'undefined') {
// the fragment might have sub fragments
var fragIdsArray = (Array.isArray(fragId) ?
fragId :
[fragId]);
//check each fragment
fragIdsArray.forEach(function (subFragId) {
//get this fragment. it is a THREE.Mesh
var mesh = _viewer.impl.getRenderProxy(
_viewer,
subFragId);
//dump the data of the fragment
//The complete transform matrix from local to world space
var frag_matrix = mesh.matrixWorld;
//The geometry used to display the fragment
var frag_geom = mesh.geometry;
// The appearance/material used to display the fragment
var frag_material = mesh.material;
});
}
}
The getRenderProxy takes the current model as parameter. Currently it supports one model only. The second parameter is the index into the mesh array. It's the index of the same geometry fragment in the various fragments arrays of the model's internal data model.
Comments