Forge Viewer Select in a multi-model context

前端 未结 1 1230
醉酒成梦
醉酒成梦 2021-01-26 12:22

We have extensions that currently leverage viewer.select() with a list of dbIds from the model.

Our customers would like to see secondary models in the same viewer, and

相关标签:
1条回答
  • 2021-01-26 13:02

    Before Forge Viewer v3.3, Viewer3D#select( dbIds, selectionType) didn't be exposed for the multi-model use case unfortunately. The 2nd argument of Viewer3D#select has been changed to Viewer3D#select( dbIds, model ). So, the below code snippets will changed to:

    var scene = viewer.impl.modelQueue();
    var models = scene.getModels();
    
    var targetIndex = ...;
    var targetModel = models[targetIndex];
    var selectionType = ...;
    
    // Method 1:
    viewer.impl.selector.setSelection( dbIds, targetModel, selectionType );
    
    // Method 2:
    model.selector.select( dbIds, selectionType );
    
    // Method 3: (After Forge Viewer v4)
    viewer.select( dbIds, targetModel );
    
    // Method 4: (After Forge Viewer v4)
    var selections = [
        {
           model: targetModel,
           ids: dbIds
        }
    ];
    viewer.impl.selector.setAggregateSelection( selections );
    

    ==== Update End ====

    Unfortunately, Viewer3D#select didn't be exposed for the multi-model use case. However, there are few ways to select items via the API in multi-model environment:

    var scene = viewer.impl.modelQueue();
    var models = scene.getModels();
    
    var targetIndex = ...;
    var targetModel = models[targetIndex];
    var selectionType = ...;
    
    // Method 1:
    viewer.impl.selector.setSelection( dbIds, targetModel, selectionType );
    
    // Method 2:
    model.selector.select( dbIds, selectionType );
    
    // Method 3: (After Forge Viewer v4)
    var selections = [
        {
           model: targetModel,
           ids: dbIds
        }
    ];
    viewer.impl.selector.setAggregateSelection( selections );
    

    Or, you can write your own Viewer class which extends Autodesk.Viewing.Viewer3D or Autodesk.Viewing.Private.GuiViewer3D to private a select function that supports passing model argument.

    0 讨论(0)
提交回复
热议问题