Forge Viewer Select 在多模型上下文中 [英] Forge Viewer Select in a multi-model context

查看:27
本文介绍了Forge Viewer Select 在多模型上下文中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一些扩展,目前利用带有来自模型的 dbId 列表的 viewer.select().

我们的客户希望在同一个查看器中看到次要模型,我们让他们能够在加载第一个模型后加载参考模型.

我们遇到了多个模型的问题,但是,查看器正在从一个模型中选择而不是我们调用 viewer.select() 时加载的第一个模型.>

看起来我们可能想停止使用viewer.select(),而是在保持对第一个加载的模型的引用后开始使用model.selector.select().这意味着要更改相当多的代码.

有没有办法设置viewer.select()的上下文,让它总是使用我们加载的第一个模型?

解决方案

在 Forge Viewer v3.3 之前,Viewer3D#select( dbIds, selectionType) 没有暴露给多模型使用不幸的情况.Viewer3D#select 的第二个参数已更改为 Viewer3D#select( dbIds, model ).因此,以下代码片段将更改为:

var scene = viewer.impl.modelQueue();var 模型 = scene.getModels();var targetIndex = ...;var targetModel = 模型[targetIndex];var selectionType = ...;//方法一:viewer.impl.selector.setSelection(dbIds, targetModel, selectionType );//方法二:model.selector.select(dbIds, selectionType );//方法三:(Forge Viewer v4 之后)查看器选择(dbIds,targetModel);//方法四:(Forge Viewer v4 之后)变量选择 = [{模型:目标模型,ids: dbIds}];viewer.impl.selector.setAggregateSelection( selections );

==== 更新结束 ====

不幸的是,Viewer3D#select 没有针对多模型用例公开.但是,在多模型环境中通过 API 选择项目的方法很少:

var scene = viewer.impl.modelQueue();var 模型 = scene.getModels();var targetIndex = ...;var targetModel = 模型[targetIndex];var selectionType = ...;//方法一:viewer.impl.selector.setSelection(dbIds, targetModel, selectionType );//方法二:model.selector.select(dbIds, selectionType );//方法三:(Forge Viewer v4 之后)变量选择 = [{模型:目标模型,ids: dbIds}];viewer.impl.selector.setAggregateSelection( selections );

或者,您可以编写自己的查看器类,该类扩展 Autodesk.Viewing.Viewer3DAutodesk.Viewing.Private.GuiViewer3D 以私有 select支持传递 model 参数的 code> 函数.

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 we’re giving them the ability to load reference models after the first model has been loaded.

We’re running into a problem with multiple models, however, where the viewer is selecting from one of the models other than the first model loaded when we call viewer.select().

It seems like we may want to stop using viewer.select() but instead start using model.selector.select() after keeping a reference to the first model loaded. This would mean changing quite a bit of code.

Is there a way to set the context of viewer.select() so that it always uses the first model we load?

解决方案

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.

这篇关于Forge Viewer Select 在多模型上下文中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆