Autodesk Forge - How to stop recoloring of object when selected

最后都变了- 提交于 2019-12-11 06:58:49

问题


Our elements are color coded so when a user selects one we just want to isolate it in the views (which works as expected) BUT we don't want it to change to the selection color - where can we control this?


回答1:


Use selection event to find which object has been selected, cancel the selection and isolate the selected dbId, is this the behavior you are looking for?

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 () {

    console.log('LOAD')

    viewer.addEventListener(
        Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, function(e) {

            //console.log(e)

            if(e.selections.length) {
                var dbId = e.selections[0].dbIdArray[0]
                viewer.select([])
                viewer.isolate(dbId)
            }
        })


    return true;
  };

  _this.unload = function () {

    Autodesk.Viewing.theExtensionManager.unregisterExtension(
      "Autodesk.ADN.Viewing.Extension.Basic");

    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);



回答2:


In case you want to keep the selection just not make it blue in the UI, you can change the selection material's opacity to see-through:

viewer.impl.selectionMaterialBase.opacity = 0;
viewer.impl.selectionMaterialTop.opacity = 0;

Now when you click on an object it won't turn blue.



来源:https://stackoverflow.com/questions/39985115/autodesk-forge-how-to-stop-recoloring-of-object-when-selected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!