在Autodesk.Viewing.SELECTION_CHANGED_EVENT之前与查看器中的click进行交互

时间:2019-06-27 11:38:42

标签: autodesk-forge autodesk-viewer

我想执行一些逻辑以确定单击某个零件时是否应该选择该零件。我尝试添加以下内容:

viewer.canvas.addEventListener("click", onMouseClick);

function onMouseClick(ev) {
            var bounds = viewer.canvas.getBoundingClientRect();
            var screenX = ev.clientX - bounds.left;
            var screenY = ev.clientY - bounds.top;
            var objectId = viewer.clientToWorld(screenX, screenY, true).dbId;
            var unselectableParts = [123, 124];
            if (unselectableParts.indexOf(objectId) >= 0) {
                alert("this part is not selectable at this time");
                ev.preventDefault();
            }
        }

但这是在已触发Autodesk.Viewing.SELECTION_CHANGED_EVENT并在查看器中选择零件之后运行的。

是否有防止选择的方法?还是要将此逻辑应用于其他先前触发的事件?

0 个答案:

没有答案