簡體   English   中英

如何在Autodesk Forge Viewer中更改選擇顏色?

[英]How do you change selection color in the autodesk forge viewer?

在Forge Viewer v3中,我們設置了選擇的顏色,如下所示:

onRequestClick(e) {
  const THREE_RED_COLOR = new THREE.Color(1, 0, 0);
  NOP_VIEWER.impl.setSelectionColor(THREE_RED_COLOR);
  NOP_VIEWER.select($(e.target).parent().find(`th`).data(`attributes`));
}

在v6中,此代碼仍然按預期選擇查看器對象,但是選擇顏色保持默認的藍色,並且沒有按預期更改為紅色。 現在是否通過其他方法完成此更改? 還有其他我想念的東西嗎?

嘗試使用查看器viewer.clearSelection(); viewer.set2dSelectionColor(red) viewer.clearSelection(); viewer.set2dSelectionColor(red)

其中viewer=NOP_VIEWER; red = new THREE.Color(1,0,0) viewer=NOP_VIEWER; red = new THREE.Color(1,0,0)

這樣可以解決嗎?

當我嘗試使用Viewer v6.4.2時,您的代碼工作正常:

viewer.impl.setSelectionColor(new THREE.Color(1, 0, 0));
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT,()=>viewer.select(1))

看到它在這里行動。

您可能想在瀏覽器控制台中再次嘗試相關代碼,以找出問題所在。

編輯

如果您查看源代碼,它會明確指出它僅適用於3D模型:

/**
     * Changes the color of the selection for 3D models.
     * 
     * @example
     *  viewer.setSelectionColor(new THREE.Color(0xFF0000)); // red color
     * @param {THREE.Color} color
     * 
     * @alias Autodesk.Viewing.Viewer3D#setSelectionColor
     */
    Viewer3D.prototype.setSelectionColor = function(color, selectionType) {
        this.impl.setSelectionColor(color, selectionType);
    };

還將在Engineering中記錄功能請求,以將該功能也移植到2D模型中。

我確認它不適用於2D文件。 這是我的嘗試的屏幕截圖。

我在2個圓上調用了get Selection。 確認觀眾參與其中,並且我能夠檢測到其他選擇。

然后,當我調用setSelectionColor函數時,什么也沒發生。

在此處輸入圖片說明

暫無
暫無

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

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