Autodesk Forge - 如何在选中时停止重新着色对象

时间:2016-10-11 19:25:07

标签: autodesk-forge

我们的元素是彩色编码的,所以当用户选择一个时我们只想在视图中隔离它(按预期工作)但我们不希望它改变为选择颜色 - 我们可以在哪里控制它?

2 个答案:

答案 0 :(得分:0)

使用选择事件查找已选择的对象,取消选择并隔离所选的dbId,这是您要查找的行为吗?

AutodeskNamespace(" Autodesk.ADN.Viewing.Extension&#34);

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

答案 1 :(得分:0)

如果您想要保持选择而不是在UI中将其设为蓝色,则可以将选择材料的不透明度更改为透视:

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

现在当你点击一个物体时,它不会变成蓝色。