在多模型环境中进行Forge Viewer Select [英] Forge Viewer Select in a multi-model context

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

问题描述

我们当前具有一些扩展程序,这些扩展程序使用了reader.select()和来自模型的dbId列表.

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.

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

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().

似乎我们可能要停止使用viewer.select(),而是在保留对第一个模型加载的引用之后开始使用model.selector.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.

有没有一种方法可以设置viewer.select()的上下文,使其始终使用我们加载的第一个模型?

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

推荐答案

不幸的是,在Forge Viewer v3.3之前,Viewer3D#select( dbIds, selectionType)并未针对多模型用例公开. Viewer3D#select的第二个参数已更改为Viewer3D#select( dbIds, model ).因此,以下代码段将更改为:

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 );

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

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

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 );

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

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天全站免登陆