将元素的颜色设置为在Autodesk Forge查看器中渲染之前

发布于 2025-01-21 18:22:34 字数 258 浏览 0 评论 0原文

我们使用Forge Viewer加载模型,其中所有元素都具有相同的颜色。在Forge Viewer显示它们之前,我们需要能够动态设置这些元素的颜色。在渲染后立即更改该元素的颜色也是可以接受的,尽管不是理想的。

目前,为了可靠地更改颜色,我们需要等到整个型号加载,因为我们不知道在负载中间,元素有机会渲染而没有。这意味着我们无法真正显示该模型,因为我们将向用户显示错误的颜色,因此我们无法真正显示该模型。

是否有一种方法可以在渲染之前使用Forge DB ID设置元素的颜色?

We load the models using Forge Viewer where all the elements are of the same color. We need to be able to set the color of these elements dynamically before Forge Viewer displays them. It's also acceptable, although not ideal, to change the color of the element right after it gets rendered.

Currently it looks like in order to change the colors reliably we need to wait until the whole model is loaded, since we don't know in the middle of the load which elements got the chance to render and which didn't. This means we can't really display the model until it's fully loaded since we'll be showing users wrong colors.

Is there a way to set colors of elements using forge db ids before they get rendered?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心在旅行 2025-01-28 18:22:34

您可能有机会在对象数据被明显地加载到查看器中,例如object_tree_created_event。

   viewer.addEventListener(
    Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT,
    i=>{
      console.log('OBJECT_TREE_CREATED_EVENT')
      viewer.setThemingColor(5425,new THREE.Vector4(1,0,0,1))

    }

此外,如果您的方案是针对一组对象,或覆盖现有材料,则最好的是创建自定义材料并将材料应用于对象。在我的演示中,比setThemingColor更好。

you may have chance to access the objects data before they are loaded visibly in the viewer such as OBJECT_TREE_CREATED_EVENT.

   viewer.addEventListener(
    Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT,
    i=>{
      console.log('OBJECT_TREE_CREATED_EVENT')
      viewer.setThemingColor(5425,new THREE.Vector4(1,0,0,1))

    }

In addition, if your scenario is to a group of objects, or override the existing materials, the best is to create custom material and apply the material to the objects. better performance than setThemingColor in my demo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文