簡體   English   中英

Autodesk Forge 查看器將選擇顏色設置為默認值

[英]autodesk forge viewer set selection color to default

在 object 選擇我使用下面的代碼來更改選定的 object 顏色,

viewerApp.getCurrentViewer().impl.setSelectionColor(new THREE.Color(1, 0, 0));

它工作正常,但如何將選擇顏色設置為默認值?

我都試過了


  viewerApp.getCurrentViewer().clearSelection();

viewerApp.getCurrentViewer().clearThemingColors();

但這些方法似乎不起作用。

難道我做錯了什么? 或者更改顏色並將其恢復為默認值的最佳做法是什么?

查看器版本:6*

這個選擇顏色實際上是硬編碼的,沒有保存在任何配置中。 您需要通過指定原始顏色來重置顏色,如下所示:

 .impl.setSelectionColor(new THREE.Color(0.4, 0.6, 1));

如果目標是更改所選元素的顏色,我強烈建議改用setThemingColor 這將為定義的 dbid 設置主題顏色,這可以在任何時候輕松清除。 您可以將其連接到 select 事件,以自動清除和重新分配 colors。 您可以在初始化查看器后處理此問題。

在 v7 中:

viewerApp.getCurrentViewer().viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, event=>{
    viewerApp.getCurrentViewer().clearThemingColors();
    event.dbIdArray.forEach(id => 
    {
       viewerApp.getCurrentViewer().setThemingColor(id, new THREE.Vector4(1,0,0,1)
    })
}
) 

但是,如果您確實想采用這種方法,則必須找出默認顏色是什么,並使用setSelectionColor和這種顏色來覆蓋它:編輯感謝 Cyrille,我們現在知道了! 所以相應地調整了顏色

viewerApp.getCurrentViewer().impl.setSelectionColor(new THREE.Color(0.4, 0.6, 1));

沒有明確定義 function。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM