这应该工作...你确定你传递了正确的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)”? –