在Autodesk Forge Viewer中获取三个网格元素 [英] Get THREE.Mesh elements in Autodesk Forge Viewer

查看:198
本文介绍了在Autodesk Forge Viewer中获取三个网格元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Autodesk Forge Viewer中获得元素的THREE.Mesh对象.这是代码:

I would like to get the THREE.Mesh object of an element in Autodesk Forge Viewer. Here is the code:

var dbId;   // geometry node Id of an element
var viewer; // GuiViewer3D
var mesh = viewer.impl.getRenderProxy(viewer.model, dbId);

返回的网格对象是THREE.Mesh对象,但是具有为空的Geometry和Material,因此它是无用的.如何获得真正的THREE.Mesh对象?

The return mesh object is a THREE.Mesh object but with null Geometry and Material, so it is useless. How can I get the real THREE.Mesh object?

谢谢.

推荐答案

这取决于您要对网格进行的操作:如果要更改渲染样式,则需要获取renderProxy,如果要转换组件位置或旋转,您需要获取fragmentProxy.

It depends what you want to do with the mesh: if you want to change the render style, you need to get the renderProxy, if you want to transform the component position or rotation, you need to get the fragmentProxy.

这些方法将片段ID而不是dbId作为输入.

Those methods take as input the fragment ids not the dbId.

在以下位置找到两个示例:

Find examples for both at:

Viewing.Extension.Material

Viewing.Extension转换

您可以从选择事件中获得给定dbId的片段ID,如上面的示例所示,或者使用enumNodeFragments:

You get the fragment Ids for a given dbId either from the selection event, as illustrated in the above samples, or by using enumNodeFragments:

 var instanceTree = model.getData().instanceTree

 var fragIds = []

 instanceTree.enumNodeFragments(dbId, function(fragId){
     fragIds.push(fragId)
 })

 // to change material or transform, need to iterate all
 // fragments of a given dbId and apply same material/transform

 fragIds.forEach(function(fragId) {

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

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

这篇关于在Autodesk Forge Viewer中获取三个网格元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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