這應該工作...你確定你傳遞了正確的dbId嗎?事實上,它在我身邊。您可以試試my viewer playground。這可能是因爲您的模型存在特定問題,在這種情況下,您可以與我們分享該設計。私下如果需要。
這裏是我的測試代碼:
AutodeskNamespace("Autodesk.ADN.Viewing.Extension");
Autodesk.ADN.Viewing.Extension.Basic = function (viewer, options) {
Autodesk.Viewing.Extension.call(this, viewer, options);
var _this = this;
_this.load = function() {
viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, function(e){
if(e.dbIdArray.length) {
var dbId = e.dbIdArray[0];
console.log('DbId: ' + dbId);
viewer.setThemingColor(dbId, new THREE.Vector4(0, 1, 1,1));
}
})
return true;
};
_this.unload = function() {
return true;
};
};
Autodesk.ADN.Viewing.Extension.Basic.prototype =
Object.create(Autodesk.Viewing.Extension.prototype);
Autodesk.ADN.Viewing.Extension.Basic.prototype.constructor =
Autodesk.ADN.Viewing.Extension.Basic;
Autodesk.Viewing.theExtensionManager.registerExtension(
"Autodesk.ADN.Viewing.Extension.Basic",
Autodesk.ADN.Viewing.Extension.Basic);
謝謝你的幫助。 您的示例爲我的作品。 (WORKS)如果選擇一個對象,則取消選擇它,轉換的DWG多邊形的顏色將改變。 (FAILS)如果我將值直接設置在SELECTION_CHANGED_EVENT之外,那麼在我執行類似於選擇單擊的操作之前,顏色不會改變。 我想知道是否有一些狀態變化需要被稱爲「無效」的顏色,以便他們需要重置/重新渲染? –
你如何設置themingColor後嘗試:「viewer.impl.invalidate(false,false,true)」? –